Restored from previous forum. Originally posted by Hitman.
I want to check if a file is in the Windows Directory ("Windows" in 9x/Xp, "WINNT" in NT/2000), but I never used similar commands.
Can I do this without messing too much WinAPI? Or I missed some library? Thanks.
Well, everyone needs to do something for living.
Get %windir%, please help?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Berikco.
Maybe you can use 'getsystemdirectory' wich gives you te 'System' dir
GetSystemWindowsDirectory_ also exist i just see, works the same way as my example.
regards,
benny
http://www.benny.zeb.be
Maybe you can use 'getsystemdirectory' wich gives you te 'System' dir
Code: Select all
buffer$=Space(1024)
GetSystemDirectory_(@Buffer$,Len(buffer$))
Debug(buffer$)regards,
benny
http://www.benny.zeb.be
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Berikco.
.....before you could check if '\winnt' existed, and be pretty shure it was an 'NT" system. not anymore now.
Learned this from a bug in my one program
Regards,
Benny
http://www.benny.zeb.be
'Windows' in XP yes a know nowOriginally posted by Hitman
I want to check if a file is in the Windows Directory ("Windows" in 9x/Xp, "WINNT" in NT/2000
Learned this from a bug in my one program
Regards,
Benny
http://www.benny.zeb.be
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Hitman.
WDirName.s = Space(255)
GetWindowsDirectory_(WDirName, @Null)
Debug(WDirName)
Benny Thank your code, I don't even know why it(this one) will work,
I pointed the uSize to a non-exist variable "Null", is it a bad habit?
Well, everyone needs to do something for living.
WDirName.s = Space(255)
GetWindowsDirectory_(WDirName, @Null)
Debug(WDirName)
Benny Thank your code, I don't even know why it(this one) will work,
I pointed the uSize to a non-exist variable "Null", is it a bad habit?
Well, everyone needs to do something for living.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Berikco.
In your example, if the Pathname would be more than 255 bytes, your app could chrash because the OS is writing outside the buffer.
if you have the win32 help files in the PB help directory, and you chose help when the cursor is on the the GetWindowsDirectory function, you get this kind of help.
Regards,
Benny
http://www.benny.zeb.be
Hi Hitman,Originally posted by Hitman
WDirName.s = Space(255)
GetWindowsDirectory_(WDirName, @Null)
Debug(WDirName)
Benny Thank your code, I don't even know why it(this one) will work,
I pointed the uSize to a non-exist variable "Null", is it a bad habit?
In your example, if the Pathname would be more than 255 bytes, your app could chrash because the OS is writing outside the buffer.
if you have the win32 help files in the PB help directory, and you chose help when the cursor is on the the GetWindowsDirectory function, you get this kind of help.
Code: Select all
The GetWindowsDirectory function retrieves the path of the Windows directory. The Windows directory contains such files as Windows-based applications, initialization files, and Help files.
UINT GetWindowsDirectory(
LPTSTR lpBuffer, // address of buffer for Windows directory
UINT uSize // size of directory buffer
);
Parameters
lpBuffer
Points to the buffer to receive the null-terminated string containing the path. This path does not end with a backslash unless the Windows directory is the root directory. For example, if the Windows directory is named WINDOWS on drive C, the path of the Windows directory retrieved by this function is C:\WINDOWS. If Windows was installed in the root directory of drive C, the path retrieved is C:\.
uSize
Specifies the maximum size, in characters, of the buffer specified by the lpBuffer parameter. This value should be set to at least MAX_PATH to allow sufficient room in the buffer for the path.Benny
http://www.benny.zeb.be