, 당신은 FORMAT_MESSAGE_ALLOCATE_BUFFER을 말할 때, 당신은 포인터보다 더 할당 할 필요가 없습니다. 그런 다음 lpBuffer에 해당 포인터에 대한 포인터를 전달합니다.
TCHAR* lpMsgBuf;
if(!FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL))
{
wprintf(L"Format message failed with 0x%x\n", GetLastError());
return;
}
을 그리고 LocalFree 사용
를 호출하는 것을 잊지 마세요 또는 당신이 자신을 버퍼 할당 : 그래서 이것을 시도 또한
TCHAR lpMsgBuf[512];
if(!FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) lpMsgBuf,
512, NULL))
{
wprintf(L"Format message failed with 0x%x\n", GetLastError());
return;
}
을,이 시도 :
#include <cstdio>
#include <cstdlib>
int alloc(char** pbuff,unsigned int n)
{
*pbuff=(char*)malloc(n*sizeof(char));
}
int main()
{
char buffer[512];
printf("Address of buffer before: %p\n",&buffer);
// GCC sais: "cannot convert char (*)[512] to char** ... "
// alloc(&buffer,128);
// if i try to cast:
alloc((char**)&buffer,128);
printf("Address of buffer after: %p\n",&buffer);
// if i do it the right way:
char* p_buffer;
alloc(&p_buffer,128);
printf("Address of buffer after: %p\n",p_buffer);
return 0;
}
그것은 않습니다 변수의 주소를 변경하려고하지 마십시오. 아마도 코드가 작동하지 않는 이유 일 것입니다.
오류 코드 '0x13d'가 무엇인지 찾아 보시기 바랍니다. 예를 들어 [here] (http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382%28v=vs.100% 29.aspx) –