프로그램의 안전성을 위해 포인터의 유효성을 확인해야 하는 경우가 있다.

웹에서 "포인터 유효성 검사"라고 검사하면 쉽게 찾을 수 있는 내용으로
IsBadCodePtr
IsBadReadPtr
IsBadWritePtr
IsBadStringPtr
이 있다.

그런데 MSDN으로 찾아보면 주의할만한 내용이 있다.

각 함수별 문서 서두에는 아래와 같은 내용이 있다.

Important
This function is obsolete and should not be used. Despite its name, it does not guarantee that the pointer is valid or that the memory pointed to is safe to use. For more information, see Remarks on this page.

내용이...

이 함수는 구식이고 사용해서는 안된다.
이것은 포인터가 유효하거나 사용하기에 안전한 것을 보장하지 않는다.


뚜둥!!

그렇다. 
MS에서는 위의 함수들은 쓰지말라고 하고 있다.
아마, 이전에 만들어놨기 때문에, 하위 호환성을 위해 남겨진 함수일 것이다.

웹검색에 나타나는 내용을 보면 
아직도 현업에서 사용하고 있는 함수인거 같은데....

각 함수의 비고를 보면
선점형 멀티태스킹 환경 어쩌고 저쩌고 하면서,
structured exception handling을 사용하기를 권고하고 있다.

■ Structured Exception Handling
http://msdn.microsoft.com/en-us/library/windows/desktop/ms680657(v=vs.85).aspx 

난 MS가 하는 말이 옳다고 본다.
위 함수들은 사용하지 말고 예외처리를 사용합시다. 
Posted by 아..몰라 ㅡ.ㅡ+
,

■ 출처 : http://www.lopesoft.com/en/fmtools/info.html
윈도우 탐색기의 context메뉴 기능을 확장시켜주는 프로그램 입니다.
컴퓨터로 업무를 보시는 분들에게 매우~매우! 유용한 기능을 제공해줍니다.
한국어 언어팩도 지원하고 있습니다.

■  확장된 메뉴 예


개인적으로 메뉴를 추가 할 수 있도록 도와주기고 하고
프로그램이 자체적으로 지원해주는 기능을 선택적으로 사용할 수 도 있습니다.

■ 내장되어있는 추가 기능 설명

The built-in utilities are the following:

Command Element Types Description
Synchronize Folders Screenshot Screenshot folders Synchronizes two folders. It is possible configure the synchronization type (unidirectional, bidirectional, etc.) and the file types which must be synchronized.
Extended Delete Screenshot folders Deletes recursively specific file types from a folder. The file types are specified with wildcards, for example: *.txt, *.t??, etc.
Find And Replace Screenshot all Finds and replaces a text in all selected files. It is possible to use regular expressions.
Advanced Renamer Screenshot all Renames all the selected elements by using some patterns.
Delete Locked File locked files of any type Deletes files which are locked by any application and cannot be deleted normally.
Delete Permanently all Deletes the selected elements WITHOUT moving them to the Recycle Bin.
Change Icon Screenshot folders Changes the icon assigned to the selected folder.
Run with Arguments Screenshot files with .exe,.com,.bat extensions Run a program with parameters typed through a dialog box. 
Command Line From Here folders Open a command line window and go to selected folder.
Split File Screenshot files of any type Splits the selected file in various parts.
Join File files with .prt extension Joins the parts of a file which were previously splitted.
Copy to... Screenshot all Copies the selected elements to other folder.
Move to... Screenshot all Moves the selected elements to other folder.
Copy Name all Copies to the clipboard the name of the all selected elements.
Copy Path all Copies to the clipboard the path of the all selected elements.
Copy UNC Path all Copies to the clipboard the path of the all selected elements in UNC format (\\machine\SharedResource\Path).
Copy Internet Path all Copies to the clipboard the path of the all selected elements in Internet format (file://Path).
Copy Content all Copies to the clipboard the content of the selected element. If a folder is selected, all element names that the folder contains will be copied.
Paste Clipboard all Appends the clipboard contents into the selected elements. If a folder is selected, then will be created a file in that folder with the clipboard contents.
Attributes Screenshot all Displays a submenu which lets change the attributes of the selected elements. If a folder is selected, it is possible change the attributes recursively.
Change Time Screenshot all Changes the creation time, the last access time and/or the last write time of the selected elements. If a folder is selected, it is possible change the time recursively.
Register DLL files with .dll,.ocx extensions Registers a DLL in Windows.
Unregister DLL files with .dll,.ocx extensions Unregisters a DLL.
Create New Folder folders Creates a new folder into the selected folder.
Size of Folders folders Displays the size of the folders.
Shred Files all Lets you shred the selected files definitely so it is imposible to recovery the files with recovering tools.
Send to mail recipient all Sends an e-mail with the selected elements as attachments.
Pack to Folder all Creates a new subfolder in the current folder and moves all the selected elements to this subfolder.
Duplicate Files all Creates a new copy of the selected elements in the current folder.
Select folders Selects the elements in the Windows Explorer by its type.
NOTE: this utility does not work on Windows 7.
Create Symbolic Link  all Creates a symbolic link which is referenced to the selected element. It only works on Windows Vista or later.
Calculate and Verify Checksum files Calculates and verifies checksums of the selected elements. By calculating the checksum of a file you can verify if the file has been modified.


■ 언어팩 사용법
언어팩안의 파일(korean_dll.lng, korean_exe.lng)을
실행파일 폴더 하위의 lang폴더( C:\Program Files\LopeSoft\FileMenu Tools\lang )에 복사하면

Options > Language에 언어가 추가 됩니다.

■ 프로그램 실행 화면


'Freeware들 소개' 카테고리의 다른 글

PDF Creator - 무료 PDF 변환 프로그램  (0) 2012.05.18
[7-Zip] 공개 zip 프로그램  (0) 2012.01.03
[Notepad++] 에디터  (0) 2011.12.26
[CPU-Z] 컴퓨터 Spec 분석 프로그램  (0) 2011.10.24
Posted by 아..몰라 ㅡ.ㅡ+
,
dialog를 재정의해서 사용할 때,
불현듯 DoModal에서 ASSERT에 걸려서 실행을 못하는 경우가 있다.

■ ASSERT에 걸리는 부분 
---------------------------------------------------------------------------------
INT_PTR CDialog::DoModal()
{
// can be constructed with a resource template or InitModalIndirect
ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
m_lpDialogTemplate != NULL);
--------------------------------------------------------------------------------- 

이경우 m_lpszTemplateName,  m_hDialogTemplate,  m_lpDialogTemplate 이 모두 NULL이다.

인터넷으로 뒤져보면 resource에 문제가 있으니, resource.h를 살펴보라는 둥 어쩌고 저쩌고 나오는데, 
결론적으로 리소스 문제인것은 명확하나 resource.h를 볼 필요는 없다.

원인은 의외로 기본적인 부분에 있으니..

■ 원인
Dialog를 상속만 받은 쌩짜 class(  BaseDialog 라 칭하자 )를 만들고, 기존에 사용하던 dialog class를 대체하면 빌드 에러가 날 것이다.

예)
 error C2661: 'BaseDialog::BaseDialog' : 오버로드된 함수에서 2개의 매개 변수를 사용하지 않습니다.

그렇다.  BaseDialog에는 UI Template ID와 parent포인터를 받아주는 생성자를 만들지 않아서 발생하는 에러다.
생성자를 정의해 주자.
BaseDialog::BaseDialog(UINT nIDTemplate, CWnd* pParent)
{
      .....

 
여기가 DoModal이 ASSERT를 발생 시키는 포인트다.

급하게 정의하느라 위 처럼 만들면, 의외로 삽질하느라 시간을 허비할 수도 있다.
뭔가 빠진게 있는거 같지 않은가?
 
답) 

BaseDialog::BaseDialog(UINT nIDTemplate, CWnd* pParent)
: CDialog( nIDTemplate,  pParent )
{
      .....
}  

그렇다. 멤버 이니셜라이징을 안 한것이다.
CDialog를 재정의하면서 CDialog에 TemplateID를 설정 안 해줬으니,
 m_lpszTemplateName,  m_hDialogTemplate,  m_lpDialogTemplate 이 모두  NULL인 상황이 되는 거다.

이니셜라이징을 해주면 문제 해결.

혹시나 이런 일로 시간을 허비하는 분들이 있을까봐 포스팅 합니다.


 
Posted by 아..몰라 ㅡ.ㅡ+
,