以下函数为dll导出函数,在delphi中定时调用,第一次成功连接,第二次
socket->create()出现异常,错误号1410,郁闷3天了,这到底是什么原因?
extern "C" int _cdecl ExecuteSyn()
{
CString str;
DWORD n = 0; if (!AfxSocketInit())
{
return FALSE;
} CSocket *pSocket = NULL;
pSocket = new CSocket; TRY{
if(pSocket->Create()){
::AfxMessageBox("successful");
}else{
n = ::GetLastError();
str.Format("%d", n);
::AfxMessageBox(str);
}
}
CATCH (CException, e){
n = ::GetLastError();
str.Format("%d", n);
::AfxMessageBox(str);
// ::AfxMessageBox("异常");
}
END_CATCH if(pSocket->Connect("10.188.182.219", 21)){
::AfxMessageBox("good");
}
else
::AfxMessageBox("bad");
str.Format("%d", (int)pSocket);
::AfxMessageBox(str);
if(pSocket){
delete pSocket;
pSocket = NULL;
::AfxMessageBox("release");
}
return 1;
}
socket->create()出现异常,错误号1410,郁闷3天了,这到底是什么原因?
extern "C" int _cdecl ExecuteSyn()
{
CString str;
DWORD n = 0; if (!AfxSocketInit())
{
return FALSE;
} CSocket *pSocket = NULL;
pSocket = new CSocket; TRY{
if(pSocket->Create()){
::AfxMessageBox("successful");
}else{
n = ::GetLastError();
str.Format("%d", n);
::AfxMessageBox(str);
}
}
CATCH (CException, e){
n = ::GetLastError();
str.Format("%d", n);
::AfxMessageBox(str);
// ::AfxMessageBox("异常");
}
END_CATCH if(pSocket->Connect("10.188.182.219", 21)){
::AfxMessageBox("good");
}
else
::AfxMessageBox("bad");
str.Format("%d", (int)pSocket);
::AfxMessageBox(str);
if(pSocket){
delete pSocket;
pSocket = NULL;
::AfxMessageBox("release");
}
return 1;
}
{
LPTSTR lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
MessageBox(NULL,lpMsgBuf,"ERROR",MB_OK);
LocalFree( lpMsgBuf );
}
//先close掉
delete pSocket;
pSocket = NULL;
::AfxMessageBox("release");
}
其实这个贴我发3次了,dll里,网络编程里都有
http://community.csdn.net/Expert/TopicView.asp?id=3153214这是一个被delphi写的交换系统程序定时调用vcdll里的主程序,更详细的情况请参看
上面这个贴,希望得到你们的帮助!小弟谢谢了!
参看
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/WindowClasses/WindowClassReference/WindowClassFunctions/RegisterClass.asp