Autor Beitrag
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mo 17.02.03 22:50 
Ich hoffe, dass der Post hier hinein gehört, andernfalls sollte er bitte in den entsprechenden Bereich verschoben werden.

Mein Problem ist folgendes:
Ich habe ein Programm, das auf allen Windows Versionen laufen sollte und dabei leider das Windows Verzeichnis benötigt. Da dem Genie bei der Installation des besagten OS kaum Grenzen gesetzt sind möchte ich gerne ein paar Standart Verzeichnisse, wie z.B. das Windows Verzeichnis und unter NT das AllUsersStartUp Folder, herausbekommen.
Was gibt es in dem Fall für Möglichkeiten?

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.


Zuletzt bearbeitet von derDoc am Di 18.02.03 16:04, insgesamt 1-mal bearbeitet
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 17.02.03 23:03 
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:
function GetWinDir: String;
const
  UNLEN = MAX_PATH;
var
  Size: DWORD;
begin
  Size := UNLEN + 1;
  SetLength(Result, Size);
  if GetWindowsDirectory(PChar(Result), Size) <> 0 then
    SetLength(Result, Size - 1)
  else
    Result := '';
end;

function GetSysDir: String;
const
  UNLEN = MAX_PATH;
var
  Size: DWORD;
begin
  Size := UNLEN + 1;
  SetLength(Result, Size);
  if GetSystemDirectory(PChar(Result), Size) <> 0 then
    SetLength(Result, Size - 1)
  else
    Result := '';
end;

Für den Rest siehe SHGetSpecialFolderPath im [url=www.msdn.mircosoft.com]MSDN[/url].
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mo 17.02.03 23:53 
Und noch eine kleine Anmerkung zu "Standart". Das hat nichts mit der "Art zu Stehen" zu tun. Es schreibt sich, auch wenn es sehr viele nicht wahr haben wollen, immer noch Standard.

_________________
Ist Zeit wirklich Geld?
derDoc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Di 18.02.03 16:30 
@AndyB: Danke für den Hinweis, ich habe das schon geändert. (War schon spät gestern Abend). :wink:
@Luckie: Danke für deine Beispiele. Ich werde dann mal SHGetSpecialFolderPath benutzen.

Aber nun meine Frage:
Laut dem PlatformSDK ist
Zitat:
SHGetSpecialFolderPath(HWND hwndOwner, LPTSTR lpszPath, int nFolder, BOOL fCreate);


so definiert:

Zitat:
hwndOwner
Handle to the owner window the client should specify if it displays a dialog box or message box.
lpszPath
Pointer to a null-terminated string that receives the drive and path of the specified folder. This buffer must be at least MAX_PATH characters in size.
nFolder
A CSIDL that identifies the folder of interest. If a virtual folder is specified, this function will fail.
fCreate
Indicates if the folder should be created if it does not already exist. If this value is nonzero, the folder will be created. If this value is zero, the folder will not be created.


ausblenden Quelltext
1:
SHGetSpecialFolderPath(0, aString, CSIDL_WINDOWS, 0);					


Aber ich bekomme immer nur undefinierter Bezeichner SHGetSpecialFolderPath und CSIDL_WINDOWS.
Welche Unit(s) muss ich mit einbinden?

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 19.02.03 01:09 
Was stehen denn im MSDN für Header-Files? Meist heißt die benötigten Delphi Unit gleich.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 19.02.03 10:56 
Du musst die Unit ShlObj einbinden.

Gruß
TINO
derDoc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mi 19.02.03 20:27 
Sollte es von Interesse sein, ich habe das Mal getestet und ein bischen probiert:
Für SHGetSpecialFolderPath benötigt man wie Tino schon schrieb ShlObj.
Leider kann man mit SHGetSpecialFolderPath nicht alle Verzeichnisse bekommen.
Für manche, wie etwa CSIDL_WINDOWS muss man SHGetFolderPath benutzen und benötigt dafür die Unit SHFolder.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.