2 Replies - 7768 Views - Last Post: 24 September 2006 - 01:16 AM Rate Topic: -----

#1 sajadkk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-September 06

How can i detect windows folder automatically using c++?

Post icon  Posted 23 September 2006 - 08:26 PM

How can i detect windows folder automaticaly using c++?
that is i want to detect windows folder and want to store a file int it using c++,please help me.

This post has been edited by sajadkk: 23 September 2006 - 08:32 PM

Is This A Good Question/Topic? 0
  • +

Replies To: How can i detect windows folder automatically using c++?

#2 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: How can i detect windows folder automatically using c++?

Posted 23 September 2006 - 09:34 PM

View Postsajadkk, on 24 Sep, 2006 - 08:56 AM, said:

How can i detect windows folder automaticaly using c++?
that is i want to detect windows folder and want to store a file int it using c++,please help me.

That's not possible through standard C++. You will need to use external library for that.
Was This Post Helpful? 0
  • +
  • -

#3 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: How can i detect windows folder automatically using c++?

Posted 24 September 2006 - 01:16 AM

View PostXing, on 24 Sep, 2006 - 10:04 AM, said:

That's not possible through standard C++. You will need to use external library for that.

That is obvious...any OS specific feature can be implemented only using external libraries.
Since he asked specifically for Windows, I don't think he is writing his application for multiple platforms.
So portability doesn't have much importance here.


View Postsajadkk, on 24 Sep, 2006 - 08:56 AM, said:

How can i detect windows folder automaticaly using c++?
that is i want to detect windows folder and want to store a file int it using c++,please help me.

You can use the GetWindowsDirectory API Function defined in windows.h like this:
   char s[255];
   GetWindowsDirectory(s,255);


After the function call, s will contain the path of the Windows Directory.

Here's the Function Prototype Information about this API Function:

Quote

UINT GetWindowsDirectory(
LPTSTR lpBuffer, // address of buffer for Windows directory
UINT uSize // size of directory buffer
);

Parameters
lpBuffer
Pointer to the buffer to receive the null-terminated string containing the path. This path does not end with a backslash unless the Windows directory is the root directory. For example, if the Windows directory is named WINDOWS on drive C, the path of the Windows directory retrieved by this function is C:\WINDOWS. If the system was installed in the root directory of drive C, the path retrieved is C:\.

uSize
Specifies the maximum size, in characters, of the buffer specified by the lpBuffer parameter. This value should be set to at least MAX_PATH to allow sufficient room in the buffer for the path.

(Source) : MSDN

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1