# Get the windows version & directory using C++ ??



## AZPC (Dec 13, 2006)

Hi everybody 

How can I get what version of windows the machine is running ( 95 98 2000 XP .. ? )
and how can I find its directory ( C:\WINNT , C:\WINDOWS , *X*:\WINNT .... )

*using C++*

Thanks in Advance!


----------



## AZPC (Dec 13, 2006)

and plzzzzzzzzzzzzzzzzz... without using external class.


----------



## Chicon (Jul 29, 2004)

Hi AZPC,

There is an example on the following page :

http://msdn2.microsoft.com/en-us/library/ak37a69s(VS.80).aspx


----------



## AZPC (Dec 13, 2006)

Chicon said:


> Hi AZPC,
> 
> There is an example on the following page :
> 
> http://msdn2.microsoft.com/en-us/library/ak37a69s(VS.80).aspx


WoW :up::up:

Thanks dude!!!!!!!!!!!!

but it didn't work with Borland C++  no idea why ! -- maybe because it is .NET C++

anyway I need the other thing it is more important!

I couldn't use %windir%


----------



## AZPC (Dec 13, 2006)

I found it !!!!!!!!!!!!!!!!!!!!

```
TCHAR OSDir[MAX_PATH];

GetWindowsDirectory (OSDir,MAX_PATH);
::MessageBox (NULL,OSDir,"1",MB_OK);
```
Cool . . .

now how to get the version without the .Net stuff ( I really hate it! )


----------



## IMM (Feb 1, 2002)

The following sort of thing would work using the CSIDL_WINDOWS (0x0024) value if borland provides the required include (shlobj.h)
If not, you would likely need to use one of the PSDKs with your BC for the shell method.

```
int GetSpecialDir(int dir_csidl, char *buf) {
  int status;
  
  if (!strlen(buf))
    status = SHGetSpecialFolderPathA(NULL, buf, dir_csidl, 0);
  return status;
}

//called as
status = GetSpecialDir(CSIDL_WINDOWS, (LPSTR)&cDirName);
```
values can be found at
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp?frame=true

Alternatively, you could read it from the registry, or ...
Lot's of ways to skin that cat 

-----
for winver info - see
http://msdn2.microsoft.com/en-gb/library/ms724429(d=printer).aspx
and
http://msdn2.microsoft.com/en-gb/library/ms724832(d=printer).aspx
http://msdn2.microsoft.com/en-gb/library/ms725492(d=printer).aspx


----------

