Desktop Path??

This is a discussion on Desktop Path?? within the Windows Programming forums, part of the Platform Specific Boards category; hi@all i want my prog to save itselfe on current desktop. iīm sure there is a easy way to find ...

  1. #1
    Unregistered
    Guest

    Question Desktop Path??

    hi@all

    i want my prog to save itselfe on current desktop.
    iīm sure there is a easy way to find out the path of the current userīs desktop without finding out who the current user is.

    iīm kind of c++ newbee, so please think of this by answering my question.

    thanx
    grundlos

  2. #2
    Unregistered
    Guest
    Hi!

    i would suggets to use shell functions like
    SHGetDesktopFolder

    regards,
    bob

  3. #3
    Unregistered
    Guest
    thanx.

    iīve already tried the shell-function.
    maby someone can give me little support for using it correctly.

    my compiler (borland c++ builder) outputs errors in the shlobj.h

    when i select ansi konversion there are errors in dstring.h and many other headers.

    (maby because i can not use precompiled headers with ansi to compile shlobj.h)

    greetings
    grundlos

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    You could simply query the registry value.....

    Put this function in your code and use it when you want the path of the desktop as a string

    Code:
    #include <windows.h>
    #include <iostream>
    using std::cout;
    using std::endl;
    #include <string>
    using std::string;
    
    char* GetDesktopPath(void){
    ULONG ulDataType;
    HKEY hKey;
    DWORD dwToRead = 100;
    static char strPath[100];
    char strKey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
    
    RegOpenKeyEx(HKEY_CURRENT_USER,strKey,
    			 0,KEY_READ,&hKey);
    RegQueryValueEx(hKey,"Desktop",NULL,
    			&ulDataType,(LPBYTE)strPath,&dwToRead);
    strPath[dwToRead] = '\0';
    RegCloseKey(hKey);
    return strPath;
    }
    
    int main()
    {
    cout << GetDesktopPath() << endl;
    
    return 0;
    
    }
    You need to include the windows.h in your application......


    I tested it on Win2000 & Win98 and it worked fine......have a try
    Last edited by Fordy; 02-22-2002 at 03:44 AM.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    37
    yeayeayea!!!! thanx Fordy.
    working fine.
    thanxthanxthanx again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Can't figure out what keeps hanging up my program
    By shays in forum C Programming
    Replies: 7
    Last Post: 11-12-2007, 01:59 PM
  3. Shortest path problem
    By Digitalxero in forum C++ Programming
    Replies: 0
    Last Post: 10-25-2005, 05:32 PM
  4. Path Finding Using Adjacency List.
    By DeepBlackMagic in forum C++ Programming
    Replies: 7
    Last Post: 05-16-2005, 02:34 PM
  5. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21