TestDll.exe调用cache.dll中的导出函数cache,在Win7下工作正常,但是在XP下执行到gethostbyname就会崩溃,如果把cache.dll编译为EXE那么cache函数在Win7和XP下都能正常,用户要求cache函数必须要在DLL中实现。
cache函数很简单:__declspec(dllexport) BOOL cache()
{
char szHostName[128] = "netscape.com";WORD wVersionRequested;
WSADATA wsaData;
int err;wVersionRequested = MAKEWORD( 2, 0 );err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
return 1;
}
if (gethostbyname(szHostName) != NULL)
{ printf("gethostbyname success:%s\n", szHostName);
return 1;
}
else
{
printf("gethostbyname fail:%s\n", szHostName);
}
printf("After call gethostbyname\n");
return TRUE;}在XP下的报错截图和可执行文件在附件中,麻烦各位大哥了gethostbyname crash
cache函数很简单:__declspec(dllexport) BOOL cache()
{
char szHostName[128] = "netscape.com";WORD wVersionRequested;
WSADATA wsaData;
int err;wVersionRequested = MAKEWORD( 2, 0 );err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
return 1;
}
if (gethostbyname(szHostName) != NULL)
{ printf("gethostbyname success:%s\n", szHostName);
return 1;
}
else
{
printf("gethostbyname fail:%s\n", szHostName);
}
printf("After call gethostbyname\n");
return TRUE;}在XP下的报错截图和可执行文件在附件中,麻烦各位大哥了gethostbyname crash
设为1.1试试。
我试过了,没用的