이에 오류가:GetLastError0x13d
-
13-11-2019 - |
문제
이 샘플에서 dwerror 가 10045L
.하지만 이 코드를 반환 0x13d 값 오류가 있습니다.을 얻는 방법은 형식으로 메시지가?참조하시기 바랍니다.
TCHAR lpMsgBuf[512];
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;
}
해결책
0x13d==317== ERROR_MR_MID_NOT_FOUND
.에 대한 메시지 오류가 당신을 찾으려고 하지 않에 존재하는 시스템입니다.어쩌면 당신의 오류에서 발생한 특정한 dll 나 드라이버.당신이 알고 있는 경우는 dll\드라이버려고 abtain 그것은 처리 및 지정 FORMAT_MESSAGE_FROM_HMODULE
대 FORMAT_MESSAGE_FROM_SYSTEM
공급 핸들을 소스에서 호출 FormatMessage
.
그 외에 사용하는 경우 FORMAT_MESSAGE_ALLOCATE_BUFFER
당신이해야의 변수를 선언한 유형 LPTSTR
아 LPTSTR pMsg;
과 전달을 로 사로 (LPTSTR)&pMsg
당신이 완료되면 그것으로 사용 LocalFree(pMsg)
을 출시 메모리를 할당.
다른 팁
무엇보다 먼저 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;
}
.
로컬 프리를 호출하는 것을 잊지 마십시오
또는 자신을 직접 버퍼를 할당합니다.
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;
}
.
변수의 주소를 변경하려고 시도하는 것이 좋습니다.그것은 아마도 코드가 작동하지 않는 이유입니다.