AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Treiberinstallation

Ein Thema von Nuclear-Ping · begonnen am 28. Aug 2007 · letzter Beitrag vom 30. Aug 2007
Antwort Antwort
Nuclear-Ping
(Gast)

n/a Beiträge
 
#1

Treiberinstallation

  Alt 28. Aug 2007, 11:10
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:
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;
Laut MSDN ( http://msdn2.microsoft.com/en-us/library/aa377398.aspx ) ist der Aufruf in meinen Augen korrekt: Bis auf Flags sind alles optionale Parameter. Und das was man braucht (in dem Fall "src" als Quelldatei) gibt man an. Was mach ich hier falsch?
  Mit Zitat antworten Zitat
messie

Registriert seit: 2. Mär 2005
Ort: Göttingen
1.592 Beiträge
 
Delphi 2009 Professional
 
#2

Re: Treiberinstallation

  Alt 28. Aug 2007, 11:25
Kann das sein, daß die Routine ein PWideChar statt PChar braucht?

Grüße, Messie
  Mit Zitat antworten Zitat
Nuclear-Ping
(Gast)

n/a Beiträge
 
#3

Re: Treiberinstallation

  Alt 28. Aug 2007, 12:27
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:
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]
  Mit Zitat antworten Zitat
Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#4

Re: Treiberinstallation

  Alt 29. Aug 2007, 19:58
MSDN says:
Zitat:
SourceFile
[in] Optional pointer to the file name (no path) of the file to copy. The file is looked up in the SourceDisksFiles section. The SourceFile parameter must be specified if InfContext is not. SourceFile is ignored if InfContext is specified.
I presume that the inf file must be in systemroot\inf or that you must use either supply an InfHandle if the file is in another path or that you must specify the path in SourcePathRoot parameter.

Edit: a HINF can be obtained by calling MSDN-Library durchsuchenSetupOpenInfFile, there you can give an optional path:
Zitat:
FileName
[in] Pointer to a null-terminated string containing the name (and optional path) of the INF file to be opened. If the filename does not contain path separator characters, it is searched for, first in the %windir%\inf directory, and then in the %windir%\system32 directory. If the filename contains path separator characters, it is assumed to be a full path specification and no further processing is performed on it.
  Mit Zitat antworten Zitat
Nuclear-Ping
(Gast)

n/a Beiträge
 
#5

Re: Treiberinstallation

  Alt 30. Aug 2007, 12:55
Great suggestions, thanks. But none of them work ...

Suggestion to separate file name and root path:
Delphi-Quellcode:
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;
Suggestion to use SetupOpenInfFile: I get an AV when calling SetupOpenInfFile, Read of Adress 000...
I already tried several ways, without GetMem, with GetMem, without ZeroMemory, ...
Delphi-Quellcode:
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;
[Edit]
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:
http://www.108bits.de/private/files/sources/difxapi.zip

Der Code:
Delphi-Quellcode:
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;
Das funzt. Kurze Sanduhr, Treiber ist installiert.

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 ... Wer also Fehler findet darf sie gern korrigieren und der Community 'ne optimierte Übersetzung zur Verfügung stellen.
[/Edit]
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:21 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz