我在嘗試使用此功能運行時檢查失敗#0運行的功能
void WSPAPI GetLspGuid(LPGUID lpGuid)
{
memcpy(lpGuid, &gProviderGuid, sizeof(GUID));
}
錯誤
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
的功能是通過
HMODULE hMod = NULL;
LPFN_GETLSPGUID fnGetLspGuid = NULL;
int retval = SOCKET_ERROR;
// Load teh library
hMod = LoadLibraryA(LspPath);
if (NULL == hMod)
{
fprintf(stderr, "RetrieveLspGuid: LoadLibraryA failed: %d\n", GetLastError());
goto cleanup;
}
// Get a pointer to the LSPs GetLspGuid function
fnGetLspGuid = (LPFN_GETLSPGUID) GetProcAddress(hMod, "GetLspGuid");
if (NULL == fnGetLspGuid)
{
fprintf(stderr, "RetrieveLspGuid: GetProcAddress failed: %d\n", GetLastError());
goto cleanup;
}
// Retrieve the LSPs GUID
fnGetLspGuid(Guid);
調用時此錯誤時
[奇怪的MSC 8.0錯誤:「ESP的值未正確保存在函數調用中...」](http://stackoverflow.com/questions/142644/weird-msc-8-0 -error最值的-ESP-是 - 不正確保存的,跨一個函數)。 [這個答案](http://stackoverflow.com/a/1332874/902497)討論了原因。 –
您沒有包含'LPFN_GETLSPGUID'的定義。運行時正在告訴你'LPFN_GETLSPGUID'與'GetLspGuid'不匹配。 –
@RaymondChen它被定義爲typedef void(* LPFN_GETLSPGUID)(GUID * lpGuid); –