library Smart;uses
SysUtils,
Classes,
Forms,
Dialogs,
Windows,
SmartWord in 'SmartWord.pas' {frmSmartWord},
pub in 'pub.pas';{$R *.res}var
AppDLL:TApplication;
ScrDLL:TScreen;//
procedure MyDLLProc(Reason:Integer);
begin
try
if Reason=DLL_PROCESS_DETACH then
begin
Application:=AppDLL;
Screen:=ScrDLL;
end;
except
on e:Exception do
begin
ShowMessage(e.Message);
end;
end;
end;//function SmartWord(App:TApplication;Scr:TScreen;DoctorName,UserName:PChar):Boolean;stdcall;
function SmartWord(DoctorName,UserName:PChar):Boolean;stdcall;
begin
//Application:=App;
//ScrDLL:=Screen;
//showmessage(doctorname);
//showmessage(username);
sDoctorName:=DoctorName;
sUserName:=UserName;
if not Assigned(frmSmartWord) then
Application.CreateForm(TfrmSmartWord,frmSmartWord);
frmSmartWord.Show;
end;exports
SmartWord;begin
try
AppDLL:=Application;
ScrDLL:=Screen;
DLLProc:=@MyDLLProc;
except
on e:Exception do
ShowMessage(e.Message);
end;
end.
用delphi来静态调用没有问题
function SmartWord(DoctorName,UserName:PChar):Boolean;stdcall;external 'Smart.dll';SmartWord(PChar('doc'),PChar('user'));VC有没有类似这个的静态调用方式?
动态调用时,loadlibrary直接返回失败
//调用dll
HINSTANCE hDll;
//FARPROC lpFunc;
hDll=LoadLibrary(LPCWSTR("Smart.DLL"));
CString strMsg ="失败";
if (!hDll)
{
AfxMessageBox(strMsg);
}
else
{
strMsg="成功";
AfxMessageBox();
}
初学VC,水平太差,望各位大侠帮我解决这个问题
SysUtils,
Classes,
Forms,
Dialogs,
Windows,
SmartWord in 'SmartWord.pas' {frmSmartWord},
pub in 'pub.pas';{$R *.res}var
AppDLL:TApplication;
ScrDLL:TScreen;//
procedure MyDLLProc(Reason:Integer);
begin
try
if Reason=DLL_PROCESS_DETACH then
begin
Application:=AppDLL;
Screen:=ScrDLL;
end;
except
on e:Exception do
begin
ShowMessage(e.Message);
end;
end;
end;//function SmartWord(App:TApplication;Scr:TScreen;DoctorName,UserName:PChar):Boolean;stdcall;
function SmartWord(DoctorName,UserName:PChar):Boolean;stdcall;
begin
//Application:=App;
//ScrDLL:=Screen;
//showmessage(doctorname);
//showmessage(username);
sDoctorName:=DoctorName;
sUserName:=UserName;
if not Assigned(frmSmartWord) then
Application.CreateForm(TfrmSmartWord,frmSmartWord);
frmSmartWord.Show;
end;exports
SmartWord;begin
try
AppDLL:=Application;
ScrDLL:=Screen;
DLLProc:=@MyDLLProc;
except
on e:Exception do
ShowMessage(e.Message);
end;
end.
用delphi来静态调用没有问题
function SmartWord(DoctorName,UserName:PChar):Boolean;stdcall;external 'Smart.dll';SmartWord(PChar('doc'),PChar('user'));VC有没有类似这个的静态调用方式?
动态调用时,loadlibrary直接返回失败
//调用dll
HINSTANCE hDll;
//FARPROC lpFunc;
hDll=LoadLibrary(LPCWSTR("Smart.DLL"));
CString strMsg ="失败";
if (!hDll)
{
AfxMessageBox(strMsg);
}
else
{
strMsg="成功";
AfxMessageBox();
}
初学VC,水平太差,望各位大侠帮我解决这个问题
typedef int(*func)(const char*,const char*);func SmartWord= (func)GetProcAddress( hDll , "SmartWord" );
SmartWord( "aaaaaa" , "b" );