|
写了个dll,导出函数如下:
extern "C" __declspec(dllexport) BOOL GetPWINHostInfo(int& hostID, char* exeDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CRegistry registry;
if(!registry.Open("SOFTWARE\\PCHostID"))
{
CInputDlg dlg;
if(dlg.DoModal() == IDOK)
{
hostID = dlg.m_nHostID;
strncpy( exeDir, dlg.m_strDir, strlen( dlg.m_strDir ) );
}
}
else
registry.Close();
return TRUE;
}
用VC来使用这个DLL没有问题:(省略写的)
int host;
char dir[50]; //这儿一定要先初始化指针
GetPWINHostInfo(host, dir);
但是用WR就出现问题了:
extern int GetPWINHostInfo(int, string<128>);
static host, dir;
load_dll("E:\\works\\VC\\PCDLL\\Release\\PCDLL.dll");
msg = GetPWINHostInfo(host, dir);
pause(msg);
load_dll("E:\\works\\VC\\PCDLL\\Release\\PCDLL.dll");
问题报错,然后异常结束,WR也跟着出现问题。导出函数里不用字符串就不会出现问题。怎么解决?WR只是类C,好像没办法用指针啊
[ Last edited by shyfish on 2005-3-3 at 12:35 ] |
|