정리

[Win32 API] 64bit OS인지 확인하려면 IsWow64Process

저장소/VC++
64bit OS의 확인은 IsWow64Process API를 사용하면 된다.
(중요한 것은 Client는 XP SP2 이상부터, Server는 2003 SP1 부터 지원된다는 것이다.
사용 전 주의가 필요하다.)

API 원형은 다음과 같다.

BOOL WINAPI IsWow64Process(
__in HANDLE hProcess,
__out PBOOL Wow64Process );

Parameters

hProcess

A handle to the process.

Wow64Process

A pointer to a value that is set to TRUE if the process is running under WOW64. Otherwise, the value is set to FALSE.

Return Value

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

If the application is a 64-bit application running under 64-bit Windows, the Wow64Process parameter is set to FALSE.

To compile an application that uses this function, define _WIN32_WINNT as 0x0501 or later. For more information, see Using the SDK Headers.


샘플 코드는 다음과 같다.
MSDN 발췌
#include <windows.h>
#include <stdio.h>

typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);

LPFN_ISWOW64PROCESS fnIsWow64Process;

BOOL IsWow64()
{
    BOOL bIsWow64 = FALSE;

    fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
        GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
  
    if (NULL != fnIsWow64Process)
    {
        if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
        {
            // handle error
        }
    }
    return bIsWow64;
}

void main()
{
    if(IsWow64())
        printf("Running on WOW64\n");
    else printf("Running on 32-bit Windows\n");
}

[Win32 API] GetSystemTime과 GetLocalTime

저장소/VC++

시간을 확인할 때 사용하는 API들이다.
다른 것도 있지만 제일 편하다.
하지만 두 API는 서로 다른 시간을 가진다.

GetLocalTime은 현재 컴퓨터의 시간을 반환하지만
GetSystemTime은 UTC 표준 시간을 반환한다.

API 이름만 놓고 생각해보면 둘다 같은 것 같으면서도 다르다.
요거요거.. 차이점 모르고 썼다가 귀찮아졌다.

MSDN 천천히 읽고 써야겠다. ㅠㅠ

[C++] __stdcall, __cdecl 그리고 Calling Convention

저장소/VC++
내용 직접 정리해야 하는데... 일단 펌질 ㅎㅎ



[출처] cafe.naver.com/win32cpp


Keyword Stack cleanup Parameter passing
__cdecl Caller Pushes parameters on the stack, in reverse order (right to left)
__stdcall Callee Pushes parameters on the stack, in reverse order (right to left)
__fastcall Callee Stored in registers, then pushed on stack
thiscall
(not a keyword)
Callee Pushed on stack; this pointer stored in ECX



함수호출 방식이 __cdecl, __pascal, __stdcall로 여러 가지가 있는 이유는 윈도우즈의 역사성에 있다. 우선 win16에서는 실행파일의 크기가 줄어들고 속도가 빠르다는 이유로 pascall 방식을 사용 했고 win32에서는 가변매개인자를 지원하는 함수를 제외한 모든 함수들은 __stdcall을 사용 한다. 만약 c 방식의 함수호출을 원한다면 __cdecl을 명시해 주어야 한다.(윈도우즈 프로그래밍에 있어서) 우선 c 방식의 함수 호출과 pascal 방식의 함수호출의 차이점을 알아보자. 첫 번째로 함수호출후 종료 시점에 호출한 함수의 스택을 정리하는 주체가 호출한 함수이냐 아니면 호출당한 함수이냐의 차이이다. 두 번째는 매개인자를 스택에 넣는 방향에 따라 나눈다. 즉, 다음과 같이 정리할 수가 있다.

(언더바는 생략가능함 )
1.인수를 스택에 집어넣는 방향에 따라서 다음과 같이 나뉘고
       pascal : 인수를 스택에 저장하는 순서를 왼쪽에서 오른쪽으로 한다.
       cdecl : 인수를 스택에 저장하는 순서를 오른쪽에서 왼쪽으로 한다.
      stdcall : 인수를 스택에 저장하는 순서를 오른쪽에서 왼쪽으로 한다.
2.스택에 인수를 pop 하는 주체에 따라서 다음과 같이 나뉘고.
      pascal : 호출을 당하는 쪽이 스택공간을 삭제한다.
      stdcall : 호출을 당하는 쪽이 스택공간을 삭제한다.
     cdecl : 호출을 하는 쪽이 스택공간을 삭제한다.
이렇게 stdcall은 pascal방식과 cdecl방식을 혼합한 형태를 띄운다
자 이제는 WinMain함수를 살펴보자 일반적으로 WinMain은 다음과 같이 선언되어 있다.

int APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, int nCmdShow )

APIENTRY는 WINAPI와 같은 형식을 나타낸다. 이것은 FAR __stdcall로 정의되어 있다. 또한 참고로 CALLBACK은 __stdcall로 정의되어 있다. 그럼 WINAPI와 __cdecl 함수의 호출 방식의 차이점을 예제로 알아보도록 하자. 아래에 두 방식으로 호출되는 간단한 예제가 있다.

#include "stdafx.h"

int __stdcall func(int i,int j);
int __cdecl func2(int i,int j);


int _tmain(int argc, _TCHAR* argv[])
{
        func(1,2);
        func2(2,3);

        return 0;
}

int __stdcall func(int i,int j)
{
        int r;
        r=i+j;
        return r;
}

int __cdecl func2(int i,int j)
{
        int r;
        r=i+j;
        return r;
}


이 함수들을 호출하는 부분을 디스어셈블 해 보갰다.


        func(1,2);
00411A1E  push        2    
00411A20  push        1    
00411A22  call        func (411069h)
        func2(2,3);
00411A27  push        3    
00411A29  push        2    
00411A2B  call        func2 (4110FFh)
00411A30  add         esp,8 <-------------- cdecl의 함수호출의 경우는 이 부분이 추가됨
        return 0;
...
...
00411AA0  ret         8    <------- func가 종료될 때
...
00411AE0  ret              <--------func2가 종료될때
...

위에 보면은 func를 호출할 때는 없는 코드가 func2에는 있는 것을 볼 수가 있다. 바로 스택을 정리 해주는 코드이다. add         esp,8 이라는 것이다. 모든 함수 호출 형식이 이와 같았다면.. 실행 화일 코드에 add         esp,8라는 명령어가 더 들어가게 된다. 따라서 이 코드가 존재하지 않는 pascall 방식이 실행크기가 작아지게 된 것이다. 파스칼 호출 방식은 속도도 저 명령어 하나 만큼 빨라지게 되는 것이다. 여기에는 8086 아키텍쳐에 관련된 명령어가 그 원인으로 등장한다. 그리고 스택을 정리한다는 것 자체가 그 함수를 호출한 뒤에 add         esp,8으로 스택포인터를 인자의 크기만큼 변경을 시킨다는 이야긴데...근데 여기서 프로시저 즉 함수를 다 수행했을때 원래 상태로 돌아가게 될 때 쓰이는 명령어는 ret이다. 함수 시작하고, 함수가 끝났을때 ret 명령어로 호출한 부분으로 넘어가게 된다. 다시 말하면 이 명령어는 실행되던 함수를 바로 빠져나가게 된다. 따라서.. 스택을 정리할 시간이 전혀 없다. 이에 8086설계자들은 함수에서 리턴이 될 때 스택포인터(SP)를 적절한 위치로 리셋을 시킬 수 있는 ret명령어를 새로 제공을 하여 이 문제를 아주 손쉽게 해결해 버렸다. 즉 ret, n 이라는 명령어를 제공했다는 셈이다..

어차피 리턴할 걸 스택 포인터가 정리되는 부분으로 아예 리턴을 해버리란 이야기다.. 이것은 가만히 앉아서 프로그램의 속도와 크기를 이점을 살리는 것이다.

add         esp,8   ; -->> 추가된 코드..

호출하는 부분에서 이렇게 코딩하는 대신 호출 받는부분에서 리턴할때 ret, 8으로 해결했다는 것이다.
이래서 속도가 더빨라지는 것이다. 크기도 줄어들고..... 생각을 한번 해보자..... 이런식의 함수가 굉장히 많이 호출된다면..  크기나 실행 시간이 증가되는건 당연하지 않겠는가 ? 이 이유로 속도와 크기가 아주 중요시 되던 시절에(windows 3.0, 3.1이 널리 사용되던 시절에) OS/2와 Windows설계자들은 API함수를 설계할때 프로그램이 느려지고 크기가 커지는 C방식을 사용하지 않고 pascal이나 fortran이 사용하고 있는 방식으로 스택 프레임을 설계 하게 되었다. 바로 이런 이유가 바로 pascal방식에 비교해서 바로 cdecl의 단점이 되는 것이다. 자 이번에는 다시 위의 cdecl 호출의 장점을 보게 되면.. 가변매개인자를 사용할 수가 있다는 것인데... 즉, 매개인자를 오른쪽에서 왼쪽으로 집어 넣는 것이 왜 중요한가? 이다.

이것은 인자의 첫번째가 어디인지 확실하다는 것이다. 즉 알려진 장소에서 첫번째 인자를 찾아낼 수 있다는 장점으로 가변인자를 허용할 수 있다. 호출이 되었을대 스택의 맨 상위부분이 인자의 첫번째임은 확실하니까.... 이것이 cdecl방식의 장점이 되는 것이다. 함수호출이 끝난후 스택을 정리할 때 호출한쪽에서는 정확하게 Stack을 사용한 사이즈를 알고있기 때문에 문제가되지 않지만 호출당한쪽에서는 또다른 정보를 가지고 사용한 Stack의 사이즈를 알아야 하기 때문에 심각한 문제가 발생할수 있다는 것이다. 그러기 때문에 stdcall은 함수호출 방식은 파스칼을 따르고 있지만 가변매개인자는 지원하지 못하는 것이다. 가변매개인자를 꼭 사용해야만 한다면 반드시 cdecl을 사용해야만 한다.

[Win32] CreateFile로 Text파일을 처리할 때

저장소/VC++

Text 파일을 처리할 때 Unicode 문자열을 그냥 저장하고 싶을 때
CreateFile/WriteFile을 이용하여 그냥 마구마구 써버리면?
하아... 이게 왜이러지? 하는 생각이 마구마구 들 것이야. ㅋㅋ
또 까묵지 말고 기억해두자.

일단 Byte Order Mark(BOM)에 대해서 알아두자.
추가로 fopen의 대해서 알아두는 것도 도움이 될 것 같다.

CreateFile API에 대한 내용은 MSDN을 참고하자.
아래 내용과 관련된 이슈도 있으니까 참고하자.
(읽어보니 Windows NT 서버쪽에서 UNC 경로를 이용하여 처리할 때 벌어지는 문제라고 함.)

내용을 다 살펴봤으면 본론을 얘기하도록 하자.
fopen과 같이 ccs= 옵션이 없기 때문에 파일을 처음 생성할 때
BOM을 지정해줘야 원하는 인코딩 형식의 Text 파일을 만들 수 있다.

CreateFile을 사용할 때 flag를 OPEN_ALWAYS로 지정하면
파일이 없을 경우 파일을 새로 생성한다.
GetLastError 함수로 에러값을 확인해보면 파일이 새로 생성된 경우엔
0이 반환되지만 파일이 이미 있는 경우에는 ERROR_ALREADY_EXISTS(183L)이 반환된다.
이 내용은 MSDN에 있으니까 다시 확인해보자.
자... 어쨌든 이 방법을 이용하여 새로 생성됐는지의 여부를 판단하는 것이다.
새로 생성? 이 때가 기회다!!
원하는 인코딩 형식의 정보를 넣어주자.
예를들어 Unicode 프로젝트에서 Unicode 문자열을 그대로 넣고 싶다면
0xFF, 0xFE를 차례대로 Write해주자.

다른 인코딩도 BOM 정보를 확인하여 처리하면 된다.
만약 ANSI 인코딩을 원한다면 물론 문자열을 Multibyte로 변환해야 한다.
그런거다. 이게 전부다. 딴거 없다. 훗... 역시 기록을 해두면 나중에 편하다니까. ㅋㅋㅋ

'저장소 > VC++' 카테고리의 다른 글

[Win32 API] GetSystemTime과 GetLocalTime  (0) 2010.05.22
[C++] __stdcall, __cdecl 그리고 Calling Convention  (0) 2010.02.17
[Error/Warning] warning C4995  (0) 2009.09.23
[Win32] GetFileAttributes  (0) 2009.09.22
[C++] Calling Convention  (0) 2009.09.22

[Error/Warning] warning C4995

저장소/VC++

MSDN을 보면 아래와 같이 설명해놨다.

오류 메시지
'function': 이름이 #pragma deprecated로 표시되었습니다.
'function': name was marked as #pragma deprecated

컴파일러에서 pragma deprecated로 표시한 함수를 발견했습니다. 이 함수는 이후 릴리스에서 제공되지 않을 수 있습니다. 다음 예제와 같이 warning pragma를 사용하여 이 경고를 해제할 수 있습니다.

뭐...
경고 쯤이야 해도 상관 없지만~
이까이꺼  warning pragma로 해제해도 되겠지만~
보고 그냥 지나칠 수 없지!

상황은 대략 아래와 같다.

\include\cstdio(49) : warning C4995: 'gets': 이름이 #pragma deprecated로 표시되었습니다.
\include\cstdio(53) : warning C4995: 'sprintf': 이름이 #pragma deprecated로 표시되었습니다.
\include\cstdio(56) : warning C4995: 'vsprintf': 이름이 #pragma deprecated로 표시되었습니다.
\include\cstring(22) : warning C4995: 'strcat': 이름이 #pragma deprecated로 표시되었습니다.
\include\cstring(23) : warning C4995: 'strcpy': 이름이 #pragma deprecated로 표시되었습니다.
\include\cwchar(36) : warning C4995: 'swprintf': 이름이 #pragma deprecated로 표시되었습니다.
\include\cwchar(37) : warning C4995: 'vswprintf': 이름이 #pragma deprecated로 표시되었습니다.
\include\cwchar(39) : warning C4995: 'wcscat': 이름이 #pragma deprecated로 표시되었습니다.
\include\cwchar(41) : warning C4995: 'wcscpy': 이름이 #pragma deprecated로 표시되었습니다.

크아아아아아ㅇ니마어림나ㅓ리마너~
뭐냐 이거... ㅡ,.ㅡ

include 항목을 살펴보았다.

...
#include <strsafe.h>
#include <list>
...
뭔가 냄새가 나는군...
strsafe와 list의 include 순서를 바꾸니 언제 그랬냐는듯 warning이 사라졌다.
흐음... 원인이 뭐였을까...
뒤적거리다 드디어 발견하다!!!!! 오오오오오오~~~~~
iosfwd
과연 흉물스럽도다!!!
list의 include 이력을 쭈욱~ 타고 올라가보면 utility라는 놈이 내부에서 iosfwd를 include하고있다.
음흉한것!!!
뭐... 그냥 그렇다는거다.
결론은 include 순서 바꾸라는거.

끝.

덧.1
어디선가 봤는데 strsafe.h를 include하면 정의 내용을 변경한다고 누군가의 블로그를 봤던 것 같은데 자세한 내용은 기억나지 않는다. 그저 맘 편하게 include 순서를 제일 마지막에 해주는 것이 몸과 마음이 편해지는 지름길이라는 것 뿐...

[Win32] GetFileAttributes

저장소/VC++



Attribute Meaning
FILE_ATTRIBUTE_ARCHIVE 일반 문서파일. 이 파일은 이동되거나 사라질 경우 이때의 상태를 마크한다.
FILE_ATTRIBUTE_COMPRESSED 압축된 파일.
FILE_ATTRIBUTE_DIRECTORY 디렉토리.
FILE_ATTRIBUTE_ENCRYPTED 암호화 파일.디렉토리의 경우 이후에 생성되는 파일과 서브 디렉토리를 암호화하며 시스템 파일에는 적용안됨.
FILE_ATTRIBUTE_HIDDEN 숨김 파일.
FILE_ATTRIBUTE_NORMAL 일반 파일.
FILE_ATTRIBUTE_OFFLINE (캐쉬된)오프라인 파일. 이 파일은 다른곳에서 사용이 불가능하다.
FILE_ATTRIBUTE_READONLY 읽기 전용 파일.
FILE_ATTRIBUTE_REPARSE_POINT 조합된 재구문분석위치 파일.
FILE_ATTRIBUTE_SPARSE_FILE sparse file.디스크공간의 필요에 의하여 제한된 매우 큰 파일. (예를 들면 파일 용량은 몇기가 바이트지만 실제적인 디스크 할당 영역은 1메가 정도 밖에 안되는 파일)
FILE_ATTRIBUTE_SYSTEM 시스템 파일.
FILE_ATTRIBUTE_TEMPORARY 임시 파일. 임시파일은 바로 입출력을 행하지 않고 가급적이면 메모리상에서 읽기와 쓰기를 수행하기 떄문에 일반 파일보다 속도가 빠르다. 응용프로그램은 임시파일을 사용한 후 삭제해야 한다. 

'저장소 > VC++' 카테고리의 다른 글

[Win32] CreateFile로 Text파일을 처리할 때  (0) 2009.10.07
[Error/Warning] warning C4995  (0) 2009.09.23
[C++] Calling Convention  (0) 2009.09.22
[MSDN][VS6.0] Windows Data Types  (0) 2009.09.22
[MSDN][VS6.0] ASSERT  (0) 2009.09.22

[C++] Calling Convention

저장소/VC++

 [호출규약 : __cdecl]   <---ANSI C 함수호출규약 

Element Implementation

Argument-passing order

인자 전달 순서

Right to left

오른쪽에서 왼쪽 순서로 스택으로 전달

Stack-maintenance responsibility

스택 정리

Calling function pops the arguments from the stack

호출한 측에서 인자를 스택에서 꺼냄

Name-decoration convention

명명 규칙

Underscore character (_) is prefixed to names

이름 앞에 언더스코어(_)가 붙음

Case-translation convention

대소문자 변환

No case translation performed

대소문자 변환 없음

 

 

[호출규약 : __stdcall] <---C++ 함수호출규약

Element Implementation

Argument-passing order

인자 전달 순서

Right to left.

오른쪽에서 왼쪽 순서로 스택으로 전달

Stack-maintenance responsibility

스택 정리

Called function pops its own arguments from the stack.

불려진 함수가 스택에서 인자를 꺼냄

Name-decoration convention

명명규칙

An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, double b ) is decorated as follows: _func@12

이름 앞에 _가 붙음. 이름 뒤에는 @표시가 붙고 그 뒤에 인자 목록의 바이트수가 10진수로 이어짐. 따라서, inf func( int a, double b )는 _func@12 와 같이 명명됨

Case-translation convention

대소문자 변환

None

없음

 

 

[호출규약 : __fastcall]

Element Implementation

Argument-passing order

인자 전달 순서

The first two DWORD or smaller arguments are passed in ECX and EDX registers; all other arguments are passed right to left.

처음 두 개의 DWORD 이하의 크기를 가지는 인자는 ECX와 EDX레지스터로 전달, 나머지 인자는 오른쪽에서 왼쪽으로 스택을 통해 전달

Stack-maintenance responsibility

스택 정리

Called function pops the arguments from the stack.

불려진 함수가 스택에서 인자를 꺼냄

Name-decoration convention

명명 규칙

At sign (@) is prefixed to names; an at sign followed by the number of bytes (in decimal) in the parameter list is suffixed to names.

이름 앞에 @가 붙음. 이름 뒤에도 @표시가 붙고 그 뒤에 인자 목록의 바이트수가 10진수로 이어짐.

Case-translation convention

대소문자 변환

No case translation performed.

변환 없음


'저장소 > VC++' 카테고리의 다른 글

[Error/Warning] warning C4995  (0) 2009.09.23
[Win32] GetFileAttributes  (0) 2009.09.22
[MSDN][VS6.0] Windows Data Types  (0) 2009.09.22
[MSDN][VS6.0] ASSERT  (0) 2009.09.22
[MSDN][VS6.0] IMPLEMENT_DYNCREATE  (0) 2009.09.22

[MSDN][VS6.0] Windows Data Types

저장소/VC++
Windows Data Types

The data types supported by Microsoft® Windows® are used to define function return values, function and message parameters, and structure members. They define the size and meaning of these elements.

The following table contains the following types: character, integer, Boolean, pointer, and handle. The character, integer, and Boolean types are common to most C compilers. Most of the pointer-type names begin with a prefix of P or LP. Handles refer to a resource that has been loaded into memory.

Type Definition
ATOM Atom. For more information, see Atoms.
BOOL Boolean variable (should be TRUE or FALSE).
BOOLEAN Boolean variable (should be TRUE or FALSE).
BYTE Byte (8 bits).
CALLBACK Calling convention for callback functions.
CHAR 8-bit Windows (ANSI) character. For more information, see Character Sets Used By Fonts.
COLORREF Red, green, blue (RGB) color value (32 bits). See COLORREF for information on this type.
CONST Variable whose value is to remain constant during execution.
CRITICAL_SECTION Critical-section object. For more information, see Critical Section Objects.
DWORD 32-bit unsigned integer.
DWORD_PTR Unsigned long type for pointer precision. Use when casting a pointer to a long type to perform pointer arithmetic.
DWORD32 32-bit unsigned integer.
DWORD64 64-bit unsigned integer.
FLOAT Floating-point variable.
HACCEL Handle to an accelerator table.
HANDLE Handle to an object.
HBITMAP Handle to a bitmap.
HBRUSH Handle to a brush.
HCONV Handle to a dynamic data exchange (DDE) conversation.
HCONVLIST Handle to a DDE conversation list.
HCURSOR Handle to a cursor.
HDC Handle to a device context (DC).
HDDEDATA Handle to DDE data.
HDESK Handle to a desktop.
HDROP Handle to an internal drop structure.
HDWP Handle to a deferred window position structure.
HENHMETAFILE Handle to an enhanced metafile.
HFILE Handle to a file opened by OpenFile, not CreateFile.
HFONT Handle to a font.
HGDIOBJ Handle to a GDI object.
HGLOBAL Handle to a global memory block.
HHOOK Handle to a hook.
HICON Handle to an icon.
HIMAGELIST Handle to an image list.
HIMC Handle to input context.
HINSTANCE Handle to an instance.
HKEY Handle to a registry key.
HKL Input locale identifier.
HLOCAL Handle to a local memory block.
HMENU Handle to a menu.
HMETAFILE Handle to a metafile.
HMODULE Handle to a module.
HMONITOR Handle to a display monitor.
HPALETTE Handle to a palette.
HPEN Handle to a pen.
HRGN Handle to a region.
HRSRC Handle to a resource.
HSZ Handle to a DDE string.
HWINSTA Handle to a window station.
HWND Handle to a window.
INT 32-bit signed integer.
INT_PTR Signed integral type for pointer precision. Use when casting a pointer to an integer to perform pointer arithmetic.
INT32 32-bit signed integer.
INT64 64-bit signed integer.
LANGID Language identifier. For more information, see Locales.
LCID Locale identifier. For more information, see Locales.
LCTYPE Locale information type. For a list, see Locale and Language Information
LONG 32-bit signed integer.
LONG_PTR Signed long type for pointer precision. Use when casting a pointer to a long to perform pointer arithmetic.
LONG32 32-bit signed integer.
LONG64 64-bit signed integer.
LONGLONG 64-bit signed integer.
LPARAM Message parameter.
LPBOOL Pointer to a BOOL.
LPBYTE Pointer to a BYTE.
LPCOLORREF Pointer to a COLORREF value.
LPCRITICAL_SECTION Pointer to a CRITICAL_SECTION.
LPCSTR Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.
LPCTSTR An LPCWSTR if UNICODE is defined, an LPCSTR otherwise.
LPCVOID Pointer to a constant of any type.
LPCWSTR Pointer to a constant null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts.
LPDWORD Pointer to a DWORD.
LPHANDLE Pointer to a HANDLE.
LPINT Pointer to an INT.
LPLONG Pointer to a LONG.
LPSTR Pointer to a null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.
LPTSTR An LPWSTR if UNICODE is defined, an LPSTR otherwise.
LPVOID Pointer to any type.
LPWORD Pointer to a WORD.
LPWSTR Pointer to a null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts.
LRESULT Signed result of message processing.
LUID Locally unique identifier.
PBOOL Pointer to a BOOL.
PBOOLEAN Pointer to a BOOL.
PBYTE Pointer to a BYTE.
PCHAR Pointer to a CHAR.
PCRITICAL_SECTION Pointer to a CRITICAL_SECTION.
PCSTR Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.
PCTSTR A PCWSTR if UNICODE is defined, a PCSTR otherwise.
PCWCH Pointer to a constant WCHAR.
PCWSTR Pointer to a constant null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts.
PDWORD Pointer to a DWORD.
PFLOAT Pointer to a FLOAT.
PHANDLE Pointer to a HANDLE.
PHKEY Pointer to an HKEY.
PINT Pointer to an INT.
PLCID Pointer to an LCID.
PLONG Pointer to a LONG.
PLUID Pointer to a LUID.
POINTER_32 32-bit pointer. On a 32-bit system, this is a native pointer. On a 64-bit system, this is a truncated 64-bit pointer.
POINTER_64 64-bit pointer. On a 64-bit system, this is a native pointer. On a 32-bit system, this is a sign-extended 32-bit pointer.
PSHORT Pointer to a SHORT.
PSTR Pointer to a null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.
PTBYTE Pointer to a TBYTE.
PTCHAR Pointer to a TCHAR.
PTSTR A PWSTR if UNICODE is defined, a PSTR otherwise.
PUCHAR Pointer to a UCHAR.
PUINT Pointer to a UINT.
PULONG Pointer to a ULONG.
PUSHORT Pointer to a USHORT.
PVOID Pointer to any type.
PWCHAR Pointer to a WCHAR.
PWORD Pointer to a WORD.
PWSTR Pointer to a null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts.
REGSAM Security access mask for registry key.
SC_HANDLE Handle to a service control manager database. For more information, see SCM Handles.
SC_LOCK Handle to a service control manager database lock. For more information, see SCM Handles.
SERVICE_STATUS_HANDLE Handle to a service status value. For more information, see SCM Handles.
SHORT Short integer (16 bits).
SIZE_T The maximum number of bytes to which a pointer can point. Use for a count that must span the full range of a pointer.
SSIZE_T Signed SIZE_T.
TBYTE A WCHAR if UNICODE is defined, a CHAR otherwise.
TCHAR A WCHAR if UNICODE is defined, a CHAR otherwise.
UCHAR Unsigned CHAR.
UINT Unsigned INT.
UINT_PTR Unsigned INT_PTR.
UINT32 Unsigned INT32.
UINT64 Unsigned INT64.
ULONG Unsigned LONG.
ULONG_PTR Unsigned LONG_PTR.
ULONG32 Unsigned LONG32.
ULONG64 Unsigned LONG64.
ULONGLONG 64-bit unsigned integer.
UNSIGNED Unsigned attribute.
USHORT Unsigned SHORT.
VOID Any type.
WCHAR 16-bit Unicode character. For more information, see Character Sets Used By Fonts.
WINAPI Calling convention for system functions.
WORD 16-bit unsigned integer.
WPARAM Message parameter.

'저장소 > VC++' 카테고리의 다른 글

[Win32] GetFileAttributes  (0) 2009.09.22
[C++] Calling Convention  (0) 2009.09.22
[MSDN][VS6.0] ASSERT  (0) 2009.09.22
[MSDN][VS6.0] IMPLEMENT_DYNCREATE  (0) 2009.09.22
[MSDN][VS6.0] RUNTIME_CLASS  (0) 2009.09.22

[MSDN][VS6.0] ASSERT

저장소/VC++

ASSERT

ASSERT( booleanExpression )

Parameters

booleanExpression

Specifies an expression (including pointer values) that evaluates to nonzero or 0.

Remarks

Evaluates its argument. If the result is 0, the macro prints a diagnostic message and aborts the program. If the condition is nonzero, it does nothing.

The diagnostic message has the form

assertion failed in file <name> in line <num>

where name is the name of the source file, and num is the line number of the assertion that failed in the source file.

In the Release version of MFC, ASSERT does not evaluate the expression and thus will not interrupt the program. If the expression must be evaluated regardless of environment, use the VERIFY macro in place of ASSERT.

Note   This function is available only in the Debug version of MFC.

Example

// example for ASSERTCAge* pcage = new CAge( 21 ); // CAge is derived from CObject.ASSERT( pcage!= NULL )ASSERT( pcage->IsKindOf( RUNTIME_CLASS( CAge ) ) )// Terminates program only if pcage is NOT a CAge*.

See Also   VERIFY

'저장소 > VC++' 카테고리의 다른 글

[C++] Calling Convention  (0) 2009.09.22
[MSDN][VS6.0] Windows Data Types  (0) 2009.09.22
[MSDN][VS6.0] IMPLEMENT_DYNCREATE  (0) 2009.09.22
[MSDN][VS6.0] RUNTIME_CLASS  (0) 2009.09.22
[MSDN][VS6.0] DECLARE_DYNCREATE  (0) 2009.09.22

[MSDN][VS6.0] IMPLEMENT_DYNCREATE

저장소/VC++

IMPLEMENT_DYNCREATE

IMPLEMENT_DYNCREATE( class_name, base_class_name )

Parameters

class_name

The actual name of the class (not enclosed in quotation marks).

base_class_name

The actual name of the base class (not enclosed in quotation marks).

Remarks

Use the IMPLEMENT_DYNCREATE macro with the DECLARE_DYNCREATE macro to enable objects of CObject-derived classes to be created dynamically at run time. The framework uses this ability to create new objects dynamically, for example, when it reads an object from disk during serialization. Add the IMPLEMENT_DYNCREATE macro in the class implementation file. For more information, seeCObject Class Topics in Visual C++ Programmer’s Guide.

If you use the DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE macros, you can then use the RUNTIME_CLASS macro and the CObject::IsKindOf member function to determine the class of your objects at run time.

If DECLARE_DYNCREATE is included in the class declaration, then IMPLEMENT_DYNCREATE must be included in the class implementation.

Example

// CAge.hclass CAge : public CObject{     int num;public:     DECLARE_DYNCREATE(CAge)};//==============// CAge.cpp#include "stdafx.h"#include "CAge.h"IMPLEMENT_DYNCREATE(CAge, CObject) 

See Also   DECLARE_DYNCREATE, RUNTIME_CLASS, CObject::IsKindOf


'저장소 > VC++' 카테고리의 다른 글

[MSDN][VS6.0] Windows Data Types  (0) 2009.09.22
[MSDN][VS6.0] ASSERT  (0) 2009.09.22
[MSDN][VS6.0] RUNTIME_CLASS  (0) 2009.09.22
[MSDN][VS6.0] DECLARE_DYNCREATE  (0) 2009.09.22
[MSDN][VS6.0] Predefined Macros  (0) 2009.09.22