VC写的接口函数:
//显示窗体
void ShowImage()
{
CShowImageDlg dlg;
dlg.DoModal(); //会执行,但是窗体不会弹出,为什么?
}Delphi调用Vc:
procedure TShowimageClass.InitLib_DLL;
Var
DLLFile : String;
begin
try
Begin
DLLFile :=ExtractFilePath(ParamStr(0))+'ShowImage.DLL';
if not FileExists(DllFile) then
begin
Application.MessageBox('动态库ShowImage.DLL丢失','信息提示',MB_ICONWARNING+MB_OK);
exit;
end;
hHandle := LoadLibrary(pchar(DLLFile));
if hHandle <> 0 then @FShowImage := GetProcAddress(hHandle,'ShowImage');
End
except
end;
end;procedure TShowimageClass.ShowImage(Str: String);
Var
m_Path : String;
begin
if Str='' then Exit;
m_Path := GetCurrentDir;
if Not FileExists(Str) then
Begin
MessageBox(Application.Handle,PChar('文件 '+Str+' 不存在!'),'系统提示',MB_OK+MB_ICONWARNING);
Exit;
End;
WriteFileName(m_Path+'\Path',PChar(Str));
FShowImage;
end;
//显示窗体
void ShowImage()
{
CShowImageDlg dlg;
dlg.DoModal(); //会执行,但是窗体不会弹出,为什么?
}Delphi调用Vc:
procedure TShowimageClass.InitLib_DLL;
Var
DLLFile : String;
begin
try
Begin
DLLFile :=ExtractFilePath(ParamStr(0))+'ShowImage.DLL';
if not FileExists(DllFile) then
begin
Application.MessageBox('动态库ShowImage.DLL丢失','信息提示',MB_ICONWARNING+MB_OK);
exit;
end;
hHandle := LoadLibrary(pchar(DLLFile));
if hHandle <> 0 then @FShowImage := GetProcAddress(hHandle,'ShowImage');
End
except
end;
end;procedure TShowimageClass.ShowImage(Str: String);
Var
m_Path : String;
begin
if Str='' then Exit;
m_Path := GetCurrentDir;
if Not FileExists(Str) then
Begin
MessageBox(Application.Handle,PChar('文件 '+Str+' 不存在!'),'系统提示',MB_OK+MB_ICONWARNING);
Exit;
End;
WriteFileName(m_Path+'\Path',PChar(Str));
FShowImage;
end;
解决方案 »
- 我如果把所有创建的类都以Object为基类,和以其他的为基类有什么区别吗?
- vs2008的vc assitant不能再用了?
- 用WriteFile向HID设备传输数据时,返回0x0000057(参数错误)
- VC 6.0中 mysql_fetch_row()函数可以访问连接Mysql数据库,代码移植到VS2010中,mysql_fetch_row()就不行
- 请问socket做服务器端怎样得到连接过来的客户端的IP地址?
- 又混淆了:LPCWSTR, TCHAR, LPCTSTR, LPSTR, LPWSTR...
- MFC中的const class
- windows高级编程指南(第三版) 中的函数没找到。
- 有一个问题,麻烦大家看一下
- 请教,关于在子对话框中控制回车键的问题。
- 一个极方便的宏:在VC中成块注释或反注释代码(源码开放,酷!)
- 请问从CWnd中派生出来的控件怎么响应双击消息
...@一个数字。这个数字的大小就是动态库的出入参的字节数大小。
我建议还是参考Delphi上的帮助吧。
上面有例子。
extern "C" BOOL PASCAL EXPORT ExportedFunction()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// normal function body here
}
#ifdef EXPORT
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __declspec(dllimport)
#endif
好歹才能跑起来呀