![]() |
Treiberinstallation
Hallo,
kennt sich jemand mit dem Thema Treiberinstallation per Code / Installer aus und kann mir irgendwie Tutorials oder Tipps geben? Hab mir schon WiX und WiXEdit angeschaut, allerdings hab ich dafür nur ein WiX-XML-Tutorial gefunden und keins für WiXEdit. Wenn ich mir WiXEdit anschaue, weiß ich nicht, ob ich erst nach links oder rechts gehen soll und selbst wenn, wüßte ich nicht, was ich da machen soll. Also kurz gesagt: Da blick ich ohne Tutorial nicht durch. Und das XML-Tutorial wollte ich mir im Moment grad ungern antun. Auch hab ich mir die SetupApi von Jedi angeschaut. Die Demos dort beschäftigten sich allerdings nur mit dem Lesen von Systeminformationen und nicht mit dem "schreiben". Ein paar Gehversuche mit "SetupInstallFile", welches eine Inf-Datei installieren soll, endeten bisher nur in Zugriffsverletzungen beim Aufruf von SetupInstallFile.
Delphi-Quellcode:
Laut MSDN (
const
InfFile = '.\drivers\NT_2K_XP\lqr\lqr_usb.inf'; var src: PChar; begin GetMem (src, Length (InfFile)); try StrCopy (src, InfFile); if SetupInstallFile ( nil, nil, src, nil, nil, SP_COPY_SOURCE_ABSOLUTE, nil, nil) then showmessage ('OK') else showmessage ('Oh Oh ...'); finally FreeMem (src); end; end; ![]() |
Re: Treiberinstallation
Kann das sein, daß die Routine ein PWideChar statt PChar braucht?
Grüße, Messie |
Re: Treiberinstallation
Hm, sollte eigentlich nicht das Problem sein. Alle API-Header-Kapselungen haben imho ne "Weiche", die Prüft ob Unicode vorliegt oder nicht. SetupInstallFile wird wohl ein Kürzel für entweder SetupInstallFileA oder SetupInstallFileW sein.
Aber ich probier's grad mal aus ... [Edit] Ne, mit PWideChar funktionierts erst garnicht. Er will PTSTR / PChar.
Delphi-Quellcode:
:gruebel:
type
{...} LPSTR = {$IFDEF USE_DELPHI_TYPES} Windows.LPSTR {$ELSE} PAnsiChar {$ENDIF}; {...} PTSTR = LPSTR; {...} function SetupInstallFile(InfHandle: HINF; InfContext: PInfContext; const SourceFile, SourcePathRoot, DestinationName: PTSTR; CopyStyle: DWORD; CopyMsgHandler: TSPFileCallback; Context: Pointer): BOOL; stdcall; [/Edit] |
Re: Treiberinstallation
MSDN says:
Zitat:
Edit: a HINF can be obtained by calling ![]() Zitat:
|
Re: Treiberinstallation
Great suggestions, thanks. But none of them work ... :(
Suggestion to separate file name and root path:
Delphi-Quellcode:
Suggestion to use SetupOpenInfFile: I get an AV when calling SetupOpenInfFile, Read of Adress 000...
const
infPath = '.\drivers\NT_2K_XP\lqr\'; infFile = 'lqr_usb.inf'; var srcPath, srcFile: PChar; begin GetMem (srcPath, Length (infPath) + 1); GetMem (srcFile, Length (infFile) + 1); StrCopy (srcPath, infPath); StrCopy (srcFile, infFile); if SetupInstallFile ( nil, nil, srcFile, srcPath, nil, SP_COPY_SOURCE_ABSOLUTE, nil, nil) then showmessage ('OK') else showmessage ('Oh Oh ...'); FreeMem (srcPath); FreeMem (srcFile); end; I already tried several ways, without GetMem, with GetMem, without ZeroMemory, ... :wall:
Delphi-Quellcode:
[Edit]
procedure TForm1.Button1Click(Sender: TObject);
const infPath = '.\drivers\NT_2K_XP\lqr\'; infFile = 'lqr_usb.inf'; var srcPath, srcFile, InfClass: PChar; Inf: HINF; ErrorLine: PUINT; begin GetMem (InfClass, 32); ZeroMemory (InfClass, 32); GetMem (srcFile, Length (infPath + infFile) + 1); StrCopy (srcFile, infPath + infFile); showmessage (srcFile); Inf := SetupOpenInfFile (srcFile, InfClass, INF_STYLE_WIN4, ErrorLine); try if SetupInstallFile ( Inf, nil, nil, nil, nil, SP_COPY_SOURCE_ABSOLUTE, nil, nil) then showmessage ('OK') else showmessage ('Failed'); finally FreeMem (srcFile); FreeMem (InfClass); SetupCloseInfFile (Inf); end; end; Ich hab ne Lösung gefunden mit der DIFxAPI von MSDN! :) Hab parallel zu dem Vorhaben mit SetupApi die difxapi.h nach Delphi übersetzt - soweit das meine Kenntnisse zuliesen - und scheinbar klappt das. Die Header-Datei: ![]() Der Code:
Delphi-Quellcode:
Das funzt. Kurze Sanduhr, Treiber ist installiert. :corky:
const
lqrInfFile: String = '.\drivers\NT_2K_XP\lqr\lqr_usb.inf'; ftdiInfFile1: String = '.\drivers\NT_2K_XP\rs232\FTDIPORT.INF'; ftdiInfFile2: String = '.\drivers\NT_2K_XP\rs232\FTDIBUS.INF'; var NR: Boolean; Info: PCINSTALLERINFO_A; begin GetMem (Info, 128); Info.pApplicationId := 'AppGUID'; Info.pDisplayName := 'ApplicationDisplayName'; Info.pProductName := 'YourProductName'; Info.pMfgName := 'ManufacturerName'; DriverPackageInstall (PChar (ftdiInfFile1), DRIVER_PACKAGE_FORCE or DRIVER_PACKAGE_LEGACY_MODE, Info, NR); FreeMem (Info); {...} end; Allerdings hab ich hier bei der Übersetzung der Header-Datei wohl auch bissl geschlampt. Wenn ich Info nil übergebe (was bei MSDN ok ist), bekomme ich nach der Funktion eine AV, der Treiber wird aber trotzdem installiert. Auch funktioniert "DriverPackagePreinstall" scheinbar nicht, da dort gleich mal garnix passiert, weder Sanduhr noch Treiberinstallation. Bin halt kein C'ler ... :P Wer also Fehler findet darf sie gern korrigieren und der Community 'ne optimierte Übersetzung zur Verfügung stellen. [/Edit] |
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:05 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz