Autor Beitrag
FriFra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 17.06.03 00:20 
Ich habe folgende Funktion in meinem Programm:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
  function GetVolumeName(Drive: string): string;
  var
    dummy: DWORD;
    buffer: array[0..MAX_PATH] of Char;
    oldmode: LongInt;
  begin
    Result := '';
    if Length(Drive) <= 3 then
    begin
      oldmode := SetErrorMode(SEM_FAILCRITICALERRORS);
      try
        GetVolumeInformation(PChar(Drive), buffer, SizeOf(buffer), nil, dummy,
          dummy, nil0);
        Result := StrPas(buffer);
      finally
        SetErrorMode(oldmode);
      end;
    end;
  end;


Unter WinXP funktioniert alles wunderbar, aber unter NT4 popt immer eine Fehlermeldung auf, dass sich kein Datenträger in Laufwerk A befinden würde... da ist allerdings sehr lästig, da es sich um eine Serverapplikation handelt.

_________________
Michael
(principal certified lotus professional - developer)
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Di 17.06.03 01:41 
Bei mir habe ich unter W2000 ähnliche Probleme. Was ist das bloß?

P.S.: kommst Du am 28.6. ? Notebook bring ich dann mit, dann sehn wir mal.

_________________
Gruß
Hansa
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Di 17.06.03 19:39 
Der Code ist schon in Ordnung. Gemäss MSDN sollte der Drive aber mit einen Backslash terminiert werden:


Zitat:
lpRootPathName
[in] Pointer to a string that contains the root directory of the volume to
be described. If this parameter is NULL, the root of the current directory
is used. A trailing backslash is required. For example, you would specify
\\MyServer\MyShare as \\MyServer\MyShare\, or the C drive as "C:\".


Also z.B 'A:\'
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 17.06.03 21:03 
Der übergebene Drive ist "A:\", also mit "\" terminiert. Trotzdem kommt der Dialog... Die Funktion soll aber keinen Dialog ausgeben, egal was passiert :evil:, wenn ein Fehler auftritt soll eben ein leerer String zurück geliefert werden, aber ohne die Belästigung durch den Dialog...

_________________
Michael
(principal certified lotus professional - developer)