Eg
if test.dll exist in win dir the do nothing
if not then
copy test.dll to the windows directory
HELP!!!!!!!
(From 'Delphi 5 Developer's Guide' by Teixeira and Pacheco):
var
WDir: string;
begin
SetLength(WDir, 144);
If GetWindowsDirectory(pchar(WDir), 144) <> 0 then
begin
SetLength(WDir, StrLen(PChar(WDir)));
ShowMessage(WDir);
End
Else
RaiseLastWin32Error;
End;
"Mark Solesbury" <mark_so...@lineone.net> wrote in message
news:pD7l7.1046$zi3.5...@news2-win.server.ntlworld.com...
> SetLength(WDir, 144);
> If GetWindowsDirectory(pchar(WDir), 144) <> 0 then
> begin
> SetLength(WDir, StrLen(PChar(WDir)));
>
MSDN recommends to use MAX_PATH as the length of the initial string,
GetWindowsDirecory returns the actual length of the string. I always use
(ignoring error protection for the example) ...
WinDir : string
WinDirLen : integer;
begin
WinDirLen := MAX_PATH;
SetLength(WinDir, WinDirLen);
WinDirLen := GetWindowsDirectory(PChar(WinDir), WinDirLen);
SetLength(WinDir, WinDirLen);
...
Not that the API returns "C:\" for a root windows directory and "C:\Windows"
for a non-root directory. If you want to cater for a root windows directory
(pretty unlikely) you must handle the different trailing characters.
Alan Lloyd
alang...@aol.com