Autor Beitrag
Boldar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Di 28.07.09 14:26 
Hi,
ich stelle jetzt mal hier eine Frage, die Mich schon lange beschäftigt:
ich habe in irgendeiner Codesammlung (ich glaube von den Schweizern) diese funktion gefunden:
ausblenden Delphi-Quelltext
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:
function GetFileNameFromHandle(hFile: Cardinal) : PChar;
var
hFileMap: Cardinal;
pMem: Pointer;
FileName: array[0..MAX_PATH] of char;
begin
  hFileMap:=CreateFileMapping(hFile, nil, PAGE_READONLY, 01nil);
  if hfilemap=0 then
  begin
    result := '';
    exit;
  end;
  pMem:=MapViewOfFile(hFileMap, FILE_MAP_READ, 001);
  if pmem=nil then
  begin
    result := '';
    CloseHandle(hFileMap);
    exit;
  end;
  if getcurrentprocess=0 then
  begin
    result := '';
    exit;
  end;
  GetMappedFileName(GetCurrentProcess, pMem, FileName, MAX_PATH);
  result:=FileName;
  UnmapViewOfFile(pMem);
  CloseHandle(hFileMap);
end;


Die benutze ich, um Dateipfade aus dem Filehandle zu bekommen.
Jedoch bekomme ich ausgaben in Form von
ausblenden Quelltext
1:
\Device\HarddiskVolume1\Dokumente und Einstellungen\xxxxx\Anwendungsdaten\Mozilla\Firefox\Profiles\xxxxxx\cookies.sqlite-journal740					


Woher kommt dass und wie konvertiert man das in "Richtige" Dateipfade??
Und Woher kommt die Zahl am Ende?
mfg Boldar


Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am Di 28.07.2009 um 14:45
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 28.07.09 14:29 
Das sind sogenannte Hardware-Pfade, da Windows intern nämlich analog zu Linux mit einem einzigen virtuellen Dateibaum arbeitet, statt wie DOS jedes Laufwerk einzeln zu betrachten.

Zum Konvertieren dieser Pfade müsstest Du dir durch Weglassen der einzelnen Pfadkomponenten und Abfrage der API nach den Mountpoints (theoretisch ginge Registry, das wäre aber unsauber und Fehleranfällig) den Pfad wieder ummappen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Boldar Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Di 28.07.09 14:40 
Da eine Schnelle Suche bei Google nichts brachte: kannst du mir die entsprechenden api-Funktionen verraten?
*Liebfrag*
:flehan:
mfg Boldar
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 28.07.09 14:53 
Siehe msdn.microsoft.com/e...aa364215(VS.85).aspx Der Rest sollte sich davon ausgehend finden.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 28.07.09 14:56 
Ich hätte eher auf msdn.microsoft.com/e...aa365730(VS.85).aspx getippt.
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Di 28.07.09 14:57 
Also ich habe auch einfach mal danach in Google gesucht und dort klingt doch gleich der erste Treffer gut - oder?

Sieh das jetzt aber bitte nicht als Kritik!
Ich habe von dem Thema leider noch überhaupt keine Ahnung!...
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 28.07.09 14:58 

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
AHT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 207



BeitragVerfasst: Fr 31.07.09 17:54 
user profile iconffgorcky hat folgendes geschrieben Zum zitierten Posting springen:
Also ich habe auch einfach mal danach in Google gesucht und dort klingt doch gleich der erste Treffer gut - oder?

Sieh das jetzt aber bitte nicht als Kritik!
Ich habe von dem Thema leider noch überhaupt keine Ahnung!...

Geht, soweit ich weiß, aber erst ab XP.
Da gibt es noch QueryDosDevice und eine Möglichkeit über native API.
SAiBOT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 323
Erhaltene Danke: 6

XP SP2; 7
D7; D2009
BeitragVerfasst: Fr 31.07.09 19:46 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
// DosName-Format: "\Device\HarddiskVolume2"; LogicalName-Format: "X:\"
function DosNameToLogical(DosName:Stringvar LogicalName:String):Boolean;
var
  r,r2:String;
begin
  Result := False;
  SetLength(r, MAX_PATH+1);
  SetLength(r2, MAX_PATH+1);

  GetLogicalDriveStringsW(MAX_PATH, @r[1]);
  while pos('\', r) > 0 do
  begin
    r[3] := #00;
    QueryDosDeviceW(@r[1], @r2[1], MAX_PATH);
    if CompareMem(@r2[1], @DosName[1], Length(DosName)*SizeOf(Char))  then
    begin
      LogicalName := r[1]+':\';
      Result := True;
      break;
    end;
    Delete(r, 14);
  end;
end;


Hab' das vor einiger Zeit auch mal gemacht, ist aber ein wenig "dirty" die Funktion, schreib sie halt um :).
(ACHTUNG WIDESTRING)

_________________
Debuggers don't remove bugs, they only show them in slow-motion.