| View previous topic :: View next topic |
| Author |
Message |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Sun Aug 10, 2008 11:41 am Post subject: [C++] getting Windows Dir... |
|
|
i was wondering ..
how can i get my WINDOWS Folder's Direction through C++
and store it inside a variable ?
_________________
Stylo |
|
| Back to top |
|
 |
NothingToShow Grandmaster Cheater Supreme
Reputation: 0
Joined: 11 Jul 2007 Posts: 1579
|
Posted: Sun Aug 10, 2008 11:44 am Post subject: |
|
|
I'm sure registry is perfect for this.
Open regedit, and look around for the path.
And after you've got the name for the registry key, get it into C++ using the registry functions.
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Sun Aug 10, 2008 11:48 am Post subject: |
|
|
is it the only way to get windows direction ? :\
aren't there easier ways?
anyway thx.. i'll try to figure out where the path is stored inside the regedit
_________________
Stylo |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sun Aug 10, 2008 11:52 am Post subject: |
|
|
Lol. There are APIs for this. I included this option in my program COMPINFO. Here's the snippet.
| Code: |
LPSTR *lpBuffer = new LPSTR;
GetWindowsDirectory((LPSTR)lpBuffer, MAX_PATH);
cout<<"Windows Directory: "<<(LPSTR)lpBuffer<<"\n";
delete lpBuffer;
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
NothingToShow Grandmaster Cheater Supreme
Reputation: 0
Joined: 11 Jul 2007 Posts: 1579
|
Posted: Sun Aug 10, 2008 11:54 am Post subject: |
|
|
| oib111 wrote: | Lol. There are APIs for this. I included this option in my program COMPINFO. Here's the snippet.
| Code: |
LPSTR *lpBuffer = new LPSTR;
GetWindowsDirectory((LPSTR)lpBuffer, MAX_PATH);
cout<<"Windows Directory: "<<(LPSTR)lpBuffer<<"\n";
delete lpBuffer;
|
|
Ah, I forgot that one.
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Sun Aug 10, 2008 12:05 pm Post subject: |
|
|
i thought it's strange
must be easier way to get the windows path...
thx oib111 :] and Moller too
_________________
Stylo |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Aug 10, 2008 12:35 pm Post subject: |
|
|
| Code: | TCHAR tszWindowsDirectory[ MAX_PATH ] = {0};
GetWindowsDirectory( tszWindowsDirectory, MAX_PATH ); |
No need to use 'new'.
_________________
- Retired. |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sun Aug 10, 2008 2:11 pm Post subject: |
|
|
I know. But I was using dynamic memory in my program (so that if you did that option like 5 times, you wouldn't have five variables declared in memory).
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Aug 10, 2008 3:30 pm Post subject: |
|
|
| oib111 wrote: | | I know. But I was using dynamic memory in my program (so that if you did that option like 5 times, you wouldn't have five variables declared in memory). |
Just use one big variable to use everything for. ._.
You were only accessing one at a time, right?
_________________
|
|
| Back to top |
|
 |
|