| Autor |
Beitrag |
bumbumb
      
Beiträge: 27
|
Verfasst: Sa 14.01.06 12:25
Hallo,
ich brauche ein kurzes Beispiel wie mann eine DLL durch drücken eines Buttons laden kann. Ist dieses eigenetlich möglich? Meine DLL heist bumbumb.dll. Sie soll also nur geladen werden wenn der Button angeklickt wurde.
Danke im Voraus
bumbumb
PS: Bitte mit Beispiel!! Moderiert von Christian S.: Topic aus VCL (Visual Component Library) verschoben am Sa 14.01.2006 um 12:44
|
|
Blackheart666
      
Beiträge: 2195
XP
D3Prof, D6Pers.
|
Verfasst: Sa 14.01.06 12:44
|
|
bumbumb 
      
Beiträge: 27
|
Verfasst: Sa 14.01.06 12:51
Hallo,
das habe ich schon gemacht aber ich will beim Drücken es Buttons die Dll starten das habe ich nicht gefunden hast du ein BSP
danke
|
|
alias5000
      
Beiträge: 2145
WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
|
Verfasst: Sa 14.01.06 13:00
Dann packst du halt den Code zum laden der DLL in das OnClick-Ereignis des Buttons...
_________________ Programmers never die, they just GOSUB without RETURN
|
|
bumbumb 
      
Beiträge: 27
|
Verfasst: Sa 14.01.06 13:11
kannst du mir bitte bitte ein Bsp geben danke
|
|
alias5000
      
Beiträge: 2145
WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
|
Verfasst: Sa 14.01.06 13:14
Delphi-Quelltext 1: 2: 3: 4: 5:
| Procedure Button1Click(Sender: TObject); var begin end; |
Das ist daran so schwer?
Jetzt musst du nur noch anhand des Tutorials die DLL drin dynamisch laden.
Wie du das OnClick-Ereignis in Delphi erstellst weißt du ja wahrscheinlich.
Gruß alias5000
_________________ Programmers never die, they just GOSUB without RETURN
|
|
bumbumb 
      
Beiträge: 27
|
Verfasst: Sa 14.01.06 13:15
kannst du mir nicht eben den Code darein schreiben damit ich das weis es ist meine 1te dll danke
|
|
alias5000
      
Beiträge: 2145
WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
|
Verfasst: Sa 14.01.06 13:28
_________________ Programmers never die, they just GOSUB without RETURN
|
|
bumbumb 
      
Beiträge: 27
|
Verfasst: Sa 14.01.06 13:38
Titel: Fehler
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
| procedure TForm1.DruckenClick(Sender: TObject); var pat:integer; DLLfunction = procedure Printpage(AktNr: integer); stdcall; FuncPtr: TFarProc; DLLHandle: THandle; begin DLLHandle := LoadLibrary(PChar(r); if DLLHandle = nil then begin Showmessage('Die DLL konnte nicht gefunden werden'); exit; end; FuncPtr := GetProcAddress(DLLHandle, 'printpage'); if FuncPtr <> nil then begin @DLLFunction := FuncPtr; end;
end; |
Moderiert von Gausi: Beitragsformatierung überarbeitet.
|
|
alias5000
      
Beiträge: 2145
WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
|
Verfasst: Sa 14.01.06 13:44
_________________ Programmers never die, they just GOSUB without RETURN
|
|
bumbumb 
      
Beiträge: 27
|
Verfasst: Sa 14.01.06 13:48
aber es wird meine procedure nicht aufgerufen was kann das sein?
|
|
bumbumb 
      
Beiträge: 27
|
Verfasst: Sa 14.01.06 13:52
ok wie wird jetzt die Funktion in der DLL aufgerufen? Help danke
|
|
alias5000
      
Beiträge: 2145
WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
|
Verfasst: Sa 14.01.06 14:13
Dann schreibst du im Button1CLick einfach(jetzt nach meinem Bsp):
Delphi-Quelltext
Um die Funktion auch in anderen Prozeduren verwenden zu können, musst du die Variable DLLfunction global deklarieren. (also z.B. unter oder über implemetation)
Gruß alias5000
_________________ Programmers never die, they just GOSUB without RETURN
|
|
bumbumb 
      
Beiträge: 27
|
Verfasst: Sa 14.01.06 14:26
|
|
alias5000
      
Beiträge: 2145
WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
|
Verfasst: Sa 14.01.06 14:34
Wo hängt es denn, wo stürtzt er ab?
Stürzt er nicht mehr ab, wenn du die letzte Zeile weglässt?
_________________ Programmers never die, they just GOSUB without RETURN
|
|
bumbumb 
      
Beiträge: 27
|
Verfasst: Sa 14.01.06 14:35
ja so ist es wenn ich die letzte zeile weglasse geht es aber dann wird ja die Procedure nicht mehr aufgerufen ???
|
|
alias5000
      
Beiträge: 2145
WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
|
Verfasst: Sa 14.01.06 14:52
Dann ist es aber auch möglich, dass in der DLL-Prozedur n Fehler drinnen ist, wenn du die Source mal zeigst, können wir dir vllcht helfen
Gruß alias5000
_________________ Programmers never die, they just GOSUB without RETURN
|
|
bumbumb 
      
Beiträge: 27
|
Verfasst: Sa 14.01.06 14:54
Hallo,
ihr seit so net hier ist der Code der Dll Vielen Dank
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93:
| library peine;
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, DBTables, StdCtrls, ExtCtrls, Printers, Mask, StrUtils, jsbarcode, BarHL, Menus, jpeg, GraphicEx, WinSkinData, Grids;
{$R *.res} {$I strd} {$I fob} {$I text_out} {$I blk_codr}
{$I Taktmarke} {$I barcode}
procedure PrintPage(AktNr:integer); var zeile,spalte:integer; HaktNr,HPatNr,Nummer:string; Margins: TMargins; begin Printer.BeginDoc; GetPrinterMargins(Margins); fob_out(1.77,1.37,Margins.Left,Margins.Top,'c:\59750_1.tif'); text_out(10,2.0,'Arial',12,0,Margins.Left,Margins.Top,Copy(InTToStr(AktNr+1000000),2,6)); Nummer:=Copy(IntToStr(AktNr+1000000),2,6); HaktNr:=Copy(Nummer,1,1)+Copy(Nummer,3,1)+Copy(Nummer,5,1); HPatNr:=Copy(Nummer,2,1)+Copy(Nummer,4,1)+Copy(Nummer,6,1); block_codr(9,12.3,1.8,0.35,0.15,0.508,2.54,Margins.Left,Margins.Top,Copy(IntToStr(StrToInt(HaktNr)+1000),2,3)); block_codr(9,12.3,2.2,0.35,0.15,0.508,2.54,Margins.Left,Margins.Top,Copy(IntToStr(StrToInt(HPatNr)+1000),2,3));
for zeile:=0 to 1 do for spalte:=0 to 6 do begin text_out(0.56+Spalte*2.7,27.6+Zeile*1.65,'Arial',10,270,Margins.Left,Margins.Top,Copy(IntToStr(AktNr+1000000),2,6)); taktmarke(1.4+Spalte*2.7,24.1+1*1.7,0.35,0.15,Margins.Left,Margins.Top); barcode(true,1.4+Spalte*2.7,26.1+Zeile*1.7,1.4,0.9,CODE25i,false,SC0,Margins.Left,Margins.Top,Copy(IntToStr(AktNr+1000000),2,6)); end; Printer.EndDoc; end; exports PrintPage; end. |
Moderiert von Christian S.: Delphi-Tags hinzugefügt
|
|
Blackheart666
      
Beiträge: 2195
XP
D3Prof, D6Pers.
|
Verfasst: Sa 14.01.06 14:54
Die Function erwartet bestimmt zwei Parameter
Delphi-Quelltext 1: 2:
| DLLFunction(1122121); DLLFunction(112,2121); |
Edit - war Quatsch bin noch von der Oberen Function ausgegangen.
Zuletzt bearbeitet von Blackheart666 am Sa 14.01.06 14:58, insgesamt 1-mal bearbeitet
|
|
alias5000
      
Beiträge: 2145
WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
|
Verfasst: Sa 14.01.06 14:56
Kleine Bemerkung am Rand, würdest du bitte die Delphi Tags oben benutzen, wenn du Source-Code postest?
_________________ Programmers never die, they just GOSUB without RETURN
|
|
|