G
gooodlife
Unregistered / Unconfirmed
GUEST, unregistred user!
// Dll程序段
var
DLLForm: TDllForm;
OldHandle : THandle;
begin
// Copy application handle to DLL's TApplication object
Oldhandle := Application.Handle;
Application.Handle := AHandle;
DLLForm := TDLLForm.Create(Application);
try
DLLForm.Caption := ACaption;
DLLForm.ShowModal;
Result := DLLForm.calDLLCalendar.CalendarDate; // Pass the date back in Result
finally
DLLForm.Free;
Application.Handle := Oldhandle;
end;
// 调用程序段
var
LibHandle : THandle;
ShowCalendar: TShowCalendar;
begin
LibHandle := LoadLibrary('CALENDARLIB.DLL');
try
if LibHandle = 0 then
raise EDLLLoadError.Create('Unable to Load DLL');
@ShowCalendar := GetProcAddress(LibHandle, 'ShowCalendar');
if not (@ShowCalendar = nil) then
lblDate.Caption := DateToStr(ShowCalendar(Application.Handle, Caption))
else
RaiseLastWin32Error;
finally
FreeLibrary(LibHandle); // Unload the DLL.
end;
///////返回时出错
我已经做了保存和返回Handle 的打操作了?
var
DLLForm: TDllForm;
OldHandle : THandle;
begin
// Copy application handle to DLL's TApplication object
Oldhandle := Application.Handle;
Application.Handle := AHandle;
DLLForm := TDLLForm.Create(Application);
try
DLLForm.Caption := ACaption;
DLLForm.ShowModal;
Result := DLLForm.calDLLCalendar.CalendarDate; // Pass the date back in Result
finally
DLLForm.Free;
Application.Handle := Oldhandle;
end;
// 调用程序段
var
LibHandle : THandle;
ShowCalendar: TShowCalendar;
begin
LibHandle := LoadLibrary('CALENDARLIB.DLL');
try
if LibHandle = 0 then
raise EDLLLoadError.Create('Unable to Load DLL');
@ShowCalendar := GetProcAddress(LibHandle, 'ShowCalendar');
if not (@ShowCalendar = nil) then
lblDate.Caption := DateToStr(ShowCalendar(Application.Handle, Caption))
else
RaiseLastWin32Error;
finally
FreeLibrary(LibHandle); // Unload the DLL.
end;
///////返回时出错
我已经做了保存和返回Handle 的打操作了?