Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

how to find Windows dir?

I'm using multiple windows dirs (C:\windows, E:\Winnt, F:\Win95US) and use a program which needs to install a picture in their root. my code I use now is as follows;

Image1.Picture.Bitmap.Handle := NViewLibLoad('e:\winnt\800x600.jpg', False);

I tried using this suggested in the help file : NViewLibLoad('<systemroot>\800x600.jpg', False); but this does not work.

how does it work so the program automatically searches the root Windir of the active windows (systemroot).
0
hellfire052497
Asked:
hellfire052497
1 Solution
 
GreyfireCommented:
You can use the GetWindowsDirectory API call to get the current path to the Windows directory.  The <systemroot> label that you are attempting to use appears similiar to some of the directory labels supported by InstallShield and other installation packages.  You can also get the path to the current Windows System directory with the GetSystemDirectory call.

Using these calls are simple with Delphi.  The following code can be used:

Var
  WinDirLen: Integer;
  WinDir: PChar;
Begin
  GetMem(WinDir, 255);
  WinDirLen := GetSystemDirectory(WinDir,255);
  { Process SysDir as required perhaps just to copy to a }
  { for later processing so the memory can be dealloc'ed }
  FreeMem(WinDir);
End;

The Delphi help system contains additional information that will be useful for calling these functions.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now