Results 1 to 18 of 18

Thread: Shortcuts to C:\

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Posts
    15

    Exclamation Shortcuts to C:\

    I am wondering if it is possible to create a shortcut to C:\ through a Visual C++ program??, the operating system is XP professional, and the computers are networked, which prevents shortcuts by right clicking. (if u didnt already know that). any ideas, through programs or other things let me know please, any help will be greatly appreciated.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    There's a description of the .lnk format somewhere on the MS homepage.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    The quickest & easiest way to create a shortcut is by using the ShellExecute API:

    Code:
    #include <windows.h>
    
    int main(){
    
    	ShellExecute(NULL, "open", "C:\\", NULL, NULL, SW_NORMAL);
    	return 0;
    }
    Enjoy
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i tryed this from VC++7 and it didnt work:
    Code:
    // shell.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx"
    #include "iostream"
    #include <windows>
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	ShellExecute(NULL, "open", "C:\\", NULL, NULL, SW_NORMAL);
    	return 0;
    }
    whats the problem here?
    \m/\m/

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Code:
    // shell.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include <iostream>
    #include <windows.h>
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	ShellExecute(NULL, "open", "C:\\", NULL, NULL, SW_NORMAL);
    	return 0;
    }
    Check the blue parts
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    #include "stdafx.h"
    #include <iostream>
    #include <windows.h>

    i cant get it! what is the difference?

    #include "*.h"
    #include "*"
    #include <*.h>
    #include <*>

    where * is the name of the header..what is the difference between them? when do i know which to implement?
    \m/\m/

  7. #7
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    emm...did u edit ur post? i could swear u said bold and not blue and that the things were in bold..lol
    \m/\m/

  8. #8
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    still got an error:

    error C2065: 'ShellExecute' : undeclared identifier
    \m/\m/

  9. #9
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    #include "*.h"
    #include "*"
    #include <*.h>
    #include <*>

    #include <windows.h>
    The angular brackets are used for header files that are located in the compiler's include directory. Quotes are used for header files that are located in your project directory or elsewhere.
    #include "../inc/myclass.h"

    .h header files are depreciated; now the standards committee has decided that instead there should be no .h extension, and that the content of the header file should be located inside a namespace (often std).
    use .h if you must, or locate the appropriately new header file.
    #include <iostream.h> ==> #include <iostream>
    #include <stdlib.h> ==> #include <cstdlib>
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  10. #10
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm ah ok very tks
    \m/\m/

  11. #11
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Originally posted by PT Exorcist

    i cant get it! what is the difference?
    ( ... )
    where * is the name of the header..what is the difference between them? when do i know which to implement?
    Ok, you use the < and > when the (header)file resides in the include path (this is something that's defined by your linker, there are directories in which the linker looks for the header files by default). So most of the headers that came with your compiler will be available by using < and >.

    When you use " ", you're telling your linker that you're looking for a header file in the same dir as your cpp file (maybe you can do stuff like "MyDir/myFile.h" but I've never tried it - Now I see from the reply above that this is possible)

    Stuff in the Standard Template Library doesn't use the .h postfix, but since the Windows API isn't compatible with other systems, it's not in the Standard Template Library, so that's why there's a .h postfix.
    Iostream doesn't have a .h postfix since it's in the Standard Template Library.

    I hope I explained things well

    And yes, I edited my post, I saw that the bold parts weren't that obvious

    Edit: Hmm writing this stuff took me little too long, sunburnt was faster
    Last edited by Jop; Feb 10th, 2003 at 04:36 PM.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  12. #12
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah ok tks to you too lol
    \m/\m/

  13. #13
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Do you still get errors by the way? I think it should work just fine with the code I posted? in a console app that is
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  14. #14
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm err no..it still giving error..but it is not big trouble..u see..i am not the guy who started the topic..it was just curiosity lol
    \m/\m/

  15. #15
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Well now you made me curious why it doesn't work

    Just open a new Solution, a new empty console app project. Make a new Cpp file and paste the code below.
    Code:
    #include <windows.h>
    
    int main(){
    
    	ShellExecute(NULL, "open", "C:\\", NULL, NULL, SW_NORMAL);
    	return 0;
    }
    If everything is correct (include paths etc) it should work.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  16. #16
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    And if it works you can extend it for UNICODE:
    Code:
    #include <windows.h>
    #include <tchar.h>
    
    int _tmain(int argc, _TCHAR **argv)
    {
    	ShellExecute(NULL, _T("open"), _T("C:\\"), NULL, NULL, SW_NORMAL);
    	return 0;
    }
    Or to avoid the console window popping up, make it a win32 app subsystem windows and use
    int _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)

    instead.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  17. #17
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm ok ty after school ill try it out
    \m/\m/

  18. #18
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Originally posted by Jop
    Well now you made me curious why it doesn't work

    Just open a new Solution, a new empty console app project. Make a new Cpp file and paste the code below.
    Code:
    #include <windows.h>
    
    int main(){
    
    	ShellExecute(NULL, "open", "C:\\", NULL, NULL, SW_NORMAL);
    	return 0;
    }
    If everything is correct (include paths etc) it should work.
    that worked
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width