Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,393 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,137 people online right now. Registration is fast and FREE... Join Now!




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

 
Reply to this topicStart new topic

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

sajadkk
23 Sep, 2006 - 07:26 PM
Post #1

New D.I.C Head
*

Joined: 23 Sep, 2006
Posts: 1


My Contributions
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 Sep, 2006 - 07:32 PM
User is offlineProfile CardPM
+Quote Post

Xing
RE: How Can I Detect Windows Folder Automaticaly Using C++?
23 Sep, 2006 - 08:34 PM
Post #2

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 2 times
Dream Kudos: 1575
My Contributions
QUOTE(sajadkk @ 24 Sep, 2006 - 08:56 AM) *

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.
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: How Can I Detect Windows Folder Automaticaly Using C++?
24 Sep, 2006 - 12:16 AM
Post #3

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,935



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
QUOTE(Xing @ 24 Sep, 2006 - 10:04 AM) *

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.


QUOTE(sajadkk @ 24 Sep, 2006 - 08:56 AM) *

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:
CODE

   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

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 02:39AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month