Thread: problems with shellExecute

  1. #1
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001

    problems with shellExecute

    I have the following code:
    Code:
    void CAboutDlg::OnHelp() 
    {
    	//run shellExecute() on your html help 
    	HINSTANCE ShellExecute(CAboutDlg, NULL,"c:\\drew\\ElectronicPortfolioFiles\\help.html",NULL,0);
    	
    }
    but when i compile, i get the syntax error: 'constant'
    what am i doing wrong?
    PHP and XML
    Let's talk about SAX

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    HINSTANCE

    What is this doing here ? If you need a returnvalue, give it a name.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    heres the revised code as you recommended...
    Code:
    void CAboutDlg::OnHelp() 
    {
    	//run shellExecute() on your html help 
    	/*note:don't need to escape backslashes,still works without them*/
     
    ShellExecute(CAboutDlg, NULL,"c:\drew\ElectronicPortfolioFiles\help.html",NULL,0);
    	
    }
    but now i get this error:
    'CAboutDlg':illegal use of this type as an expression
    the reason i threw HINSTANCE in was because the MFC help example showed it there. this thing is really annoying me...
    PHP and XML
    Let's talk about SAX

  4. #4
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Post I thought

    I thought the first arg. of ShellExecute() was an HINSTANCE...Not sure though

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    thats not an arg, that is the function type,
    if you went:
    Code:
    HINSTANCE hInstance;
    hInstance = ShellExecute();
    then it would be fine, the HINSTANCE is used for error checking and such.
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  6. #6
    Davros
    Guest
    The first argument needs to be of type HWND, i.e. the handle of the window associated with you class.

    By calling:

    ShellExecute(CAboutDlg, NULL,"c:\drew\ElectronicPortfolioFiles\help.html", NULL,0);

    You seem to be trying to pass the CAboutDlg class itself, rather than a handle.

  7. #7
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    Sorry, i was giving an example of the HINSTANCE thing, wasnt worrying about parameters.
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  8. #8
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    thanks everyone, im slowly working it out...this seems stupid, but where do i look to find the dialogs window handle?? i knew i should have just used api......oh well
    PHP and XML
    Let's talk about SAX

  9. #9
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    do you have a DialogProc of some sort?

    if you do, one of the params will be: HWND hDlg
    hDlg would be the handle of ur dialog
    "There are three kinds of people in the world...
    Those that can count and those that can't."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 06:35 AM
  3. ShellExecute() string problem
    By henrikstolpe in forum Windows Programming
    Replies: 2
    Last Post: 05-21-2003, 09:54 AM
  4. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 04:35 PM