그냥 소스를 올려놓으면...
Procedure LibraryCall(Mainapp : TApplication; Const Dllname, ProcName : String);
Type
TProc = Procedure(Mainapp : TApplication; Const Dllname, ProcName : String);StdCall;
Var
PROC : TProc;
begin
H := LoadLibrary(Pchar(DllName));
If H < 32 Then Begin
ShowMessage('DLL이 존재하지 않습니다!.');
Exit;
End;
@PROC := GetProcAddress(H, Pchar('Call_TEST01'));
If not (@PROC = nil) Then
PROC(Mainapp,Pchar(DllName),Pchar(ProcName));
End;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
FreeLibrary(H);
Close;
end;
Dll은 사용에는 문제가 없는데 Close할때
Project TEST_P.exe raised exception class EAccessViolation with message 'Access violation at address 00000000. Read if address 00000000'. Process stopped. Use Step or Run to continue.
라는 메시지가 나옵니다.
제생각으론 메모리 해제를 하고 다시 Close를 해서 그런것 같은데...
어떻게 해야 합니까
꼭 좀 답변 부탁드립니다.
> 그냥 소스를 올려놓으면...
>
> Procedure LibraryCall(Mainapp : TApplication; Const Dllname, ProcName : String);
> Type
> TProc = Procedure(Mainapp : TApplication; Const Dllname, ProcName : String);StdCall;
> Var
> PROC : TProc;
> begin
> H := LoadLibrary(Pchar(DllName));
> If H < 32 Then Begin
> ShowMessage('DLL이 존재하지 않습니다!.');
> Exit;
> End;
>
> @PROC := GetProcAddress(H, Pchar('Call_TEST01'));
> If not (@PROC = nil) Then
> PROC(Mainapp,Pchar(DllName),Pchar(ProcName));
> End;
>
> procedure TForm1.BitBtn2Click(Sender: TObject);
> begin
> FreeLibrary(H);
> Close;
> end;
>
> Project TEST_P.exe raised exception class EAccessViolation with message 'Access violation at address 00000000. Read if address 00000000'. Process stopped. Use Step or Run to continue.
> 라는 메시지가 나옵니다.
>
> 제생각으론 메모리 해제를 하고 Close를 해서 그런것 같은데...
> 어떻게 해야 합니까
>
> 꼭 좀 답변 부탁드립니다.
FreeLibrary(H);
이 넘을 LibraryCall에다가 넣으시면 될것 같은데...자신은 없습니다만...
이렇게요...
...
If not (@PROC = nil) Then
PROC(Mainapp,Pchar(DllName),Pchar(ProcName));
FreeLibrary(H);
...