Autor Beitrag
SunnyDream
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 36

WinXP
Delphi 7 Personal
BeitragVerfasst: Mo 05.06.06 01:24 
Huhu liebe Community!
Nachdem in meinem Thread Hier einige neue Fragen zum Thema GEtShellFolder aufgekommen sind, dachte ich, ich mache einen neuen Thread dazu auf.
(Der Übersicht halber)

Mein Problem ist folgendes: Ich will den Temp Ordner des Nutzers feststellen, und verwende dazu die GetShellFolder Funktion:

ausblenden volle Höhe 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:
30:
31:
32:
33:
34:
35:
function GetShellFolder(CSIDL: integer): string;
var   
  pidl              : PItemIdList;   
  FolderPath        : string;   
  SystemFolder      : Integer;   
  Malloc            : IMalloc;   
begin   
  Malloc := nil;   
  FolderPath := '';   
  SHGetMalloc(Malloc);   
  if Malloc = nil then   
  begin   
    Result := FolderPath;   
    Exit;   
  end;   
  try   
    SystemFolder := CSIDL;   
    if SUCCEEDED(SHGetSpecialFolderLocation(0, SystemFolder, pidl)) then   
    begin   
      SetLength(FolderPath, max_path);   
      if SHGetPathFromIDList(pidl, PChar(FolderPath)) then   
      begin   
        SetLength(FolderPath, length(PChar(FolderPath)));   
      end;   
    end;   
    Result := FolderPath;   
  finally   
    Malloc.Free(pidl);   
  end;   
end;

// Aufruf:
const CSIDL_APPDATA = $001a;
//...
MeinSavePath := GetShellFolder(CSIDL_APPDATA);


In die Uses habe ich sowohl ShlObj als auch ShellApi geschrieben. Jedoch bringt mir das Programm dann beim Complilieren die Fehlermeldung, dass "IMalloc" ein undefinierter Bezeichner ist... Wie behebe ich dieses Problem?


(Ja die SuFu habe ich benutzt)
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Mo 05.06.06 08:54 
Hi,
das da brauchste schonmal nicht.
ausblenden Delphi-Quelltext
1:
2:
// Aufruf:
const CSIDL_APPDATA = $001a;


So, ist das MeinSavePath := GetShellFolder(CSIDL_APPDATA); ne globale Variable? Wenn ja, wo genau im Code versuchst du in die Variable zu schreiben?

Achja, CSIDL_APPDATA ist der Anwendungsdaten-Ordner und nicht der Temp-Ordner. Such mal bei MSDN nach der richtigen CSIDL.
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mo 05.06.06 10:37 
Bind noch mal ActiveX ein ;)

greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
SunnyDream Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 36

WinXP
Delphi 7 Personal
BeitragVerfasst: Mo 05.06.06 11:26 
Was für ein Active X soll ich denn einbinden?

@OnlineHome: Die MeinSavePath ist eine gloabale Variable die beim auslesen des Paths verwende. Um genau zu sein in einer Onclick Prozedur wird der Path ausgelesen, da ich ihn dort brauche.
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mo 05.06.06 11:30 
Wie, was für eins :shock:

In die uses ActiveX mit aufnehmen...

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 05.06.06 11:31 
user profile iconSunnyDream hat folgendes geschrieben:
Was für ein Active X soll ich denn einbinden?
Ich glaube, er meint uses ActiveX; Hab ich in der Liste vergessen, sorry ;-)

Edit: Naja, doppelt hält besser :mrgreen:

_________________
We are, we were and will not be.
SunnyDream Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 36

WinXP
Delphi 7 Personal
BeitragVerfasst: Mo 05.06.06 11:43 
ENDLICH scheint es zu gehen!
Aber da taucht schon der nächste Fehler auf:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.Vorschau1Click(Sender: TObject);
begin

MeinSavePath := GetShellFolder(CSIDL_APPDATA);
MeinSavePath := MeinSavePath+'temp.html';
ROutPut.PlainText:= true;
ROutPut.Lines.SaveToFile('MeinSavePath');

   //ausführen der temp.html im Internetexplorer!
  ShellExecute(Handle, 'open''iexplore.exe''"'  + MeinSavePath + '"' , 'C:\Programme\Internet Explorer\', SW_SHOWNORMAL);
end;


"Inkompatible Typen "String" und "PAnsiChar"" in Zeile 10...
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mo 05.06.06 11:48 
ShellExecute(Handle, 'open''iexplore.exe', PChar('"'  + MeinSavePath + '"') , 'C:\Programme\Internet Explorer\', SW_SHOWNORMAL);
:mrgreen:

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
SunnyDream Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 36

WinXP
Delphi 7 Personal
BeitragVerfasst: Mo 05.06.06 11:49 
Dank dir, fast schon peinlich wie schlecht ich NOCH bin =(