Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Finding Windows Directory

Finding Windows Directory

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionworkspace
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shultas
    wrote on last edited by
    #1

    Hey all. Just wondering, what would be the best way to find out what the user's windows directory is? (e.g, sometimes its c:\winnt, other times c:\windows, or whatever other ideas the user decides to come up with). I want to be able to call (HH.EXE) which resides in the users system directory to launch my HtmlHelp files. I realize that I can simply call the .CHM file with shellexecute and that will launch it as long as the file type has been defined. But I want to be on the safe side in case that file type is not defined. I preferably do not want to have to get the windows directory by accessing the environment variable "windir", but if that is the best way about it, I guess it'll suffice! If so, can someone tell me how to go about accessing this environment variable ... or if there is a better way, enlighten me? Thanks Shultas

    G B 3 Replies Last reply
    0
    • S shultas

      Hey all. Just wondering, what would be the best way to find out what the user's windows directory is? (e.g, sometimes its c:\winnt, other times c:\windows, or whatever other ideas the user decides to come up with). I want to be able to call (HH.EXE) which resides in the users system directory to launch my HtmlHelp files. I realize that I can simply call the .CHM file with shellexecute and that will launch it as long as the file type has been defined. But I want to be on the safe side in case that file type is not defined. I preferably do not want to have to get the windows directory by accessing the environment variable "windir", but if that is the best way about it, I guess it'll suffice! If so, can someone tell me how to go about accessing this environment variable ... or if there is a better way, enlighten me? Thanks Shultas

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      I think that unfortunately this is one area you have to read the environment - you didnt say what O/S here, I'm assuming NT.. try this :- #include <cstdlib> #include <iostream> using namespace std; int main() { char * sysdir = getenv("SystemRoot"); if (sysdir) cout<<"value of SystemRoot is: "<< sysdir<

      1 Reply Last reply
      0
      • S shultas

        Hey all. Just wondering, what would be the best way to find out what the user's windows directory is? (e.g, sometimes its c:\winnt, other times c:\windows, or whatever other ideas the user decides to come up with). I want to be able to call (HH.EXE) which resides in the users system directory to launch my HtmlHelp files. I realize that I can simply call the .CHM file with shellexecute and that will launch it as long as the file type has been defined. But I want to be on the safe side in case that file type is not defined. I preferably do not want to have to get the windows directory by accessing the environment variable "windir", but if that is the best way about it, I guess it'll suffice! If so, can someone tell me how to go about accessing this environment variable ... or if there is a better way, enlighten me? Thanks Shultas

        G Offline
        G Offline
        Garth J Lancaster
        wrote on last edited by
        #3

        I dont know how accurate this info is, but I'm going to contradict myself and offer this link I found after a quick look see a-la-google (and I just learnt something for today, that there does appear to be some API's for it other than looking in the environment) .. http://www.qinysoft.com/articles/vcdirectory.htm[^] hth, 'G'

        1 Reply Last reply
        0
        • S shultas

          Hey all. Just wondering, what would be the best way to find out what the user's windows directory is? (e.g, sometimes its c:\winnt, other times c:\windows, or whatever other ideas the user decides to come up with). I want to be able to call (HH.EXE) which resides in the users system directory to launch my HtmlHelp files. I realize that I can simply call the .CHM file with shellexecute and that will launch it as long as the file type has been defined. But I want to be on the safe side in case that file type is not defined. I preferably do not want to have to get the windows directory by accessing the environment variable "windir", but if that is the best way about it, I guess it'll suffice! If so, can someone tell me how to go about accessing this environment variable ... or if there is a better way, enlighten me? Thanks Shultas

          B Offline
          B Offline
          Brian D
          wrote on last edited by
          #4

          TCHAR szBuffer[MAX_PATH];
          GetWindowsDirectory(szBuffer, MAX_PATH);

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups