-=-
.
.....
  
 
RSS
Direkomendasikan menggunakan brower Opera/Chrome/Firefox. Resolusi minimal 1024x768 | Powered by ____ |
 
  
 
Nikmati Delphi-ID dalam berbagai versi tampilan :
Basic View (LOW Bandwidth)
Default View (Full)
Mobile Edition
Main Menu
..:: onWebTools ::..
..:: onLastPosts ::..
goto Postsplit sample data & header file(0)
 by andtho89
 on 23.May at 08:49
goto Postpemanggilan frame(5)
 by andtho89
 on 23.May at 02:13
goto Postjumlah komponen maksimal dalam sebuah project(6)
 by d4mnf1y32
 on 21.May at 12:16
goto Posttanya grayscale to biner dengan scanline(1)
 by luckynvic
 on 20.May at 20:44
goto Posttanya looping biner to matriks(1)
 by luckynvic
 on 20.May at 20:10
goto Postsql error:acces denied for user....(2)
 by nasbms
 on 19.May at 16:54
goto Posttanya AvLock(0)
 by azuriza
 on 19.May at 11:24
goto PostGet TDBEdit Value Menggunakan LookUp Grid(10)
 by henry_sys
 on 18.May at 11:27
goto Postmenghitung record dalam perulangan(4)
 by idhiel
 on 16.May at 13:53
goto Posttanya ascii(4)
 by mas_kofa
 on 16.May at 12:11
goto PostRawPrint Untuk Delphi XE2(0)
 by adewijaya
 on 15.May at 22:34
goto Postdatabase error..(4)
 by idhiel
 on 15.May at 15:57
goto Postbekasi, pt arila putra mahkota(3)
 by mas_kofa
 on 15.May at 15:37
goto Postbagaimana cara membaca file *.doc dg delphi?(0)
 by ficky
 on 15.May at 06:14

..:: onLast Articles ::..
..:: New Download ::..
Pascal-id.Org
Feeds -  Popular -  Latest
RE: The Longue
8 months, 3 weeks ago
RE: belajar pascal
8 months, 3 weeks ago
RE: The Longue
8 months, 3 weeks ago
RE: belajar pascal
8 months, 3 weeks ago
RE: Perkenalan dan Absen
8 months, 3 weeks ago
RE: Alhamdulillah Buka Puasa Bersama
8 months, 4 weeks ago
RE: تَقَبَّلَ اللهُ مِنَّا وَمِنْكَ - Selamat Hari Raya Idul Fitri
8 months, 4 weeks ago
Lintas Situs
«
free web site stats and visitor tracking

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
henry_sysOffline
Location:
Post subject: [Ask] Free DLL Handle  PostPosted: 11/Nov/2011 13:47
onIntermediate


Joined: 24-Sep-2011
Posts: 34

Status: Offline
Para suhu Delphi sekalian saya mau tanya dan mohon pencerahan...
saya buat 1 aplikasi dengan DLL (Dynamic Link Library) kemudian saya buat 1 aplikasi lg utk panggil DLL yg tadi.
Pada proses pemanggilan dan handle Form program berjalan dengan baik, tetapi ketika saya ingin terminate/Close program pemanggil ada pesan error Memory (Acces violation......) walaupun DLL nya udah saya Free sebelum Terminate,
ini Coding Pemanggil DLL saya
code : pascal
  1. type
  2. .......
  3. .......
  4. private
  5. MyReport : THandle;
  6. CallReport : procedure (vParentApplication: TApplication; vControl:TWinControl); stdcall;
  7. .....
  8. .....
  9. procedure TFmMain.FormCreate(Sender: TObject);
  10. begin
  11. if MyReport = 0 then
  12. MyReport := LoadLibrary('Reports.Dll');
  13. end;
  14.  
  15. procedure TFmMain.Reports1Click(Sender: TObject);
  16. begin
  17. if MyReport <> 0 then
  18. begin
  19. @CallReport := GetProcAddress(MyReport,'ShowMain');
  20. CallReport(Application, cxTabsheet1);
  21. end;
  22. end;
  23.  
  24. procedure TFmMain.Exit1Click(Sender: TObject);
  25. begin
  26. if MyReport <> 0 then
  27. FreeLibrary(MyReport);
  28.  
  29. Close;
  30. end;
Parsed in 0.005 seconds, using GeSHi


Sorce DLL nya
code : pascal
  1. procedure ShowMain(vParentApplication :TApplication; vComControl:TWinControl); stdcall;
  2. begin
  3. Application.CreateForm(TDmReports,DmReports); {Create dataModule utk Keneksi DB}
  4. Application:= vParentApplication;
  5. vControl := vComControl;
  6.  
  7. FmMainReport := TFmMainReport.CreateParented(vComControl.Handle);
  8. FmMainReport.QuMenu.Open;
  9. FmMainReport.Show;
  10. end;
  11. exports ShowMain;
Parsed in 0.003 seconds, using GeSHi

klu saya Trace error itu terjadi ketika FreeLibrary.....
mohon bantuan para master2 sekalian
 
 View user's profile Send private message  
Reply with quote Back to top
henry_sysOffline
Location:
Post subject: [Ask] Free DLL Handle  PostPosted: 11/Nov/2011 13:51
onIntermediate


Joined: 24-Sep-2011
Posts: 34

Status: Offline
[Double Thread, and Has Be Merged, by mas_kofa]

Para suhu Delphi sekalian saya mau tanya dan mohon pencerahan...
saya buat 1 aplikasi dengan DLL (Dynamic Link Library) kemudian saya buat 1 aplikasi lg utk panggil DLL yg tadi.
Pada proses pemanggilan dan handle Form program berjalan dengan baik, tetapi ketika saya ingin terminate/Close program pemanggil ada pesan error Memory (Acces violation......) walaupun DLL nya udah saya Free sebelum Terminate,
ini Coding Pemanggil DLL saya
code : pascal
  1. type
  2. .......
  3. .......
  4. private
  5. MyReport : THandle;
  6. CallReport : procedure (vParentApplication: TApplication; vControl:TWinControl); stdcall;
  7. .....
  8. .....
  9. procedure TFmMain.FormCreate(Sender: TObject);
  10. begin
  11. if MyReport = 0 then
  12. MyReport := LoadLibrary('Reports.Dll');
  13. end;
  14.  
  15. procedure TFmMain.Reports1Click(Sender: TObject);
  16. begin
  17. if MyReport <> 0 then
  18. begin
  19. @CallReport := GetProcAddress(MyReport,'ShowMain');
  20. CallReport(Application, cxTabsheet1);
  21. end;
  22. end;
  23.  
  24. procedure TFmMain.Exit1Click(Sender: TObject);
  25. begin
  26. if MyReport <> 0 then
  27. FreeLibrary(MyReport);
  28.  
  29. Close;
  30. end;
Parsed in 0.005 seconds, using GeSHi


Sorce DLL nya
code : pascal
  1. procedure ShowMain(vParentApplication :TApplication; vComControl:TWinControl); stdcall;
  2. begin
  3. Application.CreateForm(TDmReports,DmReports); {Create dataModule utk Keneksi DB}
  4. Application:= vParentApplication;
  5. vControl := vComControl;
  6.  
  7. FmMainReport := TFmMainReport.CreateParented(vComControl.Handle);
  8. FmMainReport.QuMenu.Open;
  9. FmMainReport.Show;
  10. end;
  11. exports ShowMain;
Parsed in 0.002 seconds, using GeSHi

klu saya Trace error itu terjadi ketika FreeLibrary.....
mohon bantuan para master2 sekalian
 
 View user's profile Send private message  
Reply with quote Back to top
mat_koderOffline
Location:
Post subject:   PostPosted: 17/Nov/2011 11:58
onUber-Skilled


Joined: 16-Jan-2006
Posts: 344

Status: Offline
Cuman ngeliat sepintas saja :
code : pascal
  1. Application.CreateForm(TDmReports,DmReports); {Create dataModule utk Keneksi DB}
  2. Application:= vParentApplication;
Parsed in 0.001 seconds, using GeSHi


apa memang benar-benar logix code anda seharusnya demikian?
(hanya bertanya saja - it would not generate error on compiling -)

_________________
..... good enough is not enough........
 
 View user's profile Send private message  
Reply with quote Back to top
henry_sysOffline
Location:
Post subject:   PostPosted: 18/Nov/2011 15:23
onIntermediate


Joined: 24-Sep-2011
Posts: 34

Status: Offline
      mat_koder wrote:
Cuman ngeliat sepintas saja :
code : pascal
  1. Application.CreateForm(TDmReports,DmReports); {Create dataModule utk Keneksi DB}
  2. Application:= vParentApplication;
Parsed in 0.001 seconds, using GeSHi

apa memang benar-benar logix code anda seharusnya demikian?
(hanya bertanya saja - it would not generate error on compiling -)

CreateForm itu construktor yg berguna untuk mengcreate class TDmReport dan menampungnya kedalam object dengan nama DmReport itu yg saya tahu kalau salah mohon diperbaiki,

Tetapi program itu tidak error dan Running Normal klu agan pingin lihat(bkn mksd menggurui) coba buka *.dpr project delphi biasanya secara default akan menulis
code : pascal
  1. uses
  2. .......
  3. .......
  4. begin
  5. Application.initialized;
  6. Application.CreateForm(NamaKelas,NamaObject);
  7. .....
  8. .....
  9. Application.Run;
  10. end.
Parsed in 0.001 seconds, using GeSHi

untuk kasus saya semua TForm/TComponent sudah saya inisialisasi jadi tinggal di "Create" aja
dan "Action := Cafree" untuk free Object ketika di close
Yang jadi masalah saya adalah bagaimana membuat procedure untuk memfree seleruh object yg telah saya create, baru kemudian melepas Handle tanpa klik close pada tiap Form Mohon pencerahan para master delphi sekalian.....
It'is Urgent Confused
 
 View user's profile Send private message  
Reply with quote Back to top
reminder2k1
Location: Jakarta
Post subject:   PostPosted: 19/Nov/2011 02:08
onKnowledgeable


Joined: 24-Jul-2007
Posts: 251
Location: Jakarta
Yang perlu di perhatikan ketika bermain DLL adalah, USE SHAREMEM di file .dpr yang akan mengexecute .dll tersebut...
Apakah sudah spt itu???

_________________
      Code:

uses crt;

begin
   writeln('Delphi 4ever');
end.
 
 View user's profile Send private message Send e-mail Yahoo Messenger  
Reply with quote Back to top
mat_koderOffline
Location:
Post subject:   PostPosted: 19/Nov/2011 11:39
onUber-Skilled


Joined: 16-Jan-2006
Posts: 344

Status: Offline
code : pascal
  1. Application.CreateForm(TDmReports,DmReports); {Create dataModule utk Keneksi DB}
  2. Application:= vParentApplication;
Parsed in 0.001 seconds, using GeSHi


bukankah baris2 hrs lebih dahulu dari baris 1 ( dari segi logic-nya ) ?

coba buat begini:
code : pascal
  1. var
  2. OldDLLAppHandle : THandle;
  3.  
  4. procedure ShowMain(vParentApplication :TApplication; vComControl:TWinControl); stdcall;
  5. begin
  6. Application.Handle := vParentApplication.Handle;
  7. Application.CreateForm(TDmReports,DmReports); {Create dataModule utk Keneksi DB}
  8. vControl := vComControl;
  9. �
  10. FmMainReport := TFmMainReport.CreateParented(vComControl.Handle);
  11. FmMainReport.QuMenu.Open;
  12. FmMainReport.Show;
  13. end;
  14. exports ShowMain;
  15.  
  16.  
  17. initialization
  18. OldDLLAppHandle := Application.handle;
  19.  
  20.  
  21. finalization
  22. Application.handle := OldDLLAppHandle;
Parsed in 0.004 seconds, using GeSHi


jangan lupa waktu di main-app , deklarasi ShowMain harus benar ( stdcall calling ).

_________________
..... good enough is not enough........
 
 View user's profile Send private message  
Reply with quote Back to top
henry_sysOffline
Location:
Post subject:   PostPosted: 22/Nov/2011 15:51
onIntermediate


Joined: 24-Sep-2011
Posts: 34

Status: Offline
Untuk sementara saya temukan solusi untuk memfree semua Object pada Finalization
code : pascal
  1. Initialization
  2. RegisterClass(ClassOfForm);
  3.  
  4. Finalization
  5. if Assigned(ObjectOfForm) then
  6. ObjectOfForm.Free;
  7. UnRegisterClass(ClassOfForm);
Parsed in 0.001 seconds, using GeSHi

Pada AppMain
code : pascal
  1. procedure TFmMain.CloseMainApp;
  2. begin
  3. UnRegisterModuleClasses(NamaHandle);{Procedure untuk mengeksekusi finalization pada ObjectOfForm}
  4. FreeLibrary(NamaHandle);
  5. Close;//Application.Terminate;
  6. end;
Parsed in 0.001 seconds, using GeSHi

Mohon masukan dari master-master sekalian ttg cara yg saya gunakan.....
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 12 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic





Powered by PNphpBB2 © 2003-2009 The Zafenio Team
Credits


| Register | Lost Password ? |