[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

GetWindowsDirectory

I am using InstallShield to setup a program and install 2 files needed by the program.  I thought that the best place to put these might be the windows directory.  I know that there is a function that returns the actual directory that Windows resides in.  I have used online help, but have been unsuccessful in utilizing this function correctly.  Could someone help with the syntax?
0
mikeljj
Asked:
mikeljj
1 Solution
 
jrmcgCommented:
This can be done easily with InstallShield.  If you open your IS installation program and click on the Components tab you will see a list of Components such as Program Files, Shared DLL's, Help Files, etc....  The files that you are installing should be inside one of the Component folders.  Click on the Component folder that you have the files you want to copy to the Windows Directory and in the "property" box in the window on the right, double-click the destination property.  In here you can select the Windows directory, or the Windows System directory, or the Program Files directory, or your Main program target directory, and so on.  Just click the top folder which is the Windows Operating System directory.  This will then be the directory that all of the files in that component folder will be copied to.  If you have other files in the same folder that you do not want copied here then I would suggest making a separate component folder for these files.

This is all using IS 5.1 or higher.  If your version does not work like this then let me know.
All of the code you write for the installation should be done inside InstallShield Scripting.  InstallShield has created its own functions that will handle anything you may need to do, and implements them inside their own 'Script' code files.

Let me know if you need further help, but if you follow the directions above you should have no problems....

J.R.
0
 
mikeljjAuthor Commented:
I know how to use InstallShield,  just not the GetWindowsDirectory command with MFC and Visual C++ in my program.
0
 
thresher_sharkCommented:
Answer coming...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
thresher_sharkCommented:
The use of this function is really rather simple, with some elaboration.  First, I will explain the parameters you pass it.  The first parameter you pass it is a buffer, declared something like this:

char path_to_windows_directory[MAX_PATH];

The second parameter is the size of the first parameter in bytes.  The value in this case is MAX_PATH.

Here is an example of the usage of GetWindowsDirectory:

char path_to_windows[MAX_PATH];  // MAX_PATH is a fairly large number to
                                 // ensure that the complete path can fit
                                 // in the variable.  Some users, after all,
                                 // might have windows installed in some
                                 // really long named directory (folder).

GetWindowsDirectory (path_to_windows, MAX_PATH);

That's it!  If you have any additional questions regarding the use of the function, please feel free to ask.  Thanks!
0
 
Answers2000Commented:
One addition to thresher's comment - a final slash (\) is included if Windows is in a root directory (uncommon but possible) - and not included if Windows isn't

Make sure you allow for this!
0
 
thresher_sharkCommented:
Yes, good point Answers2000.
0
 
mikeljjAuthor Commented:
Thank you
0
 
thresher_sharkCommented:
Sure, no problem. :-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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