ShellExecute() string problem

This is a discussion on ShellExecute() string problem within the Windows Programming forums, part of the Platform Specific Boards category; Hi all! I have a weird problem that may involve pointer problems or incorrect termination, but I have almost given ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    2

    ShellExecute() string problem

    Hi all!

    I have a weird problem that may involve pointer problems or incorrect termination, but I have almost given up now!!!

    I use a Windows API32 function called "ShellExecute()"
    to launch any application from within my application.

    The application name is stored in a charbuffer just after the string "Execute ".

    The idea is that by sending an email to my application, a user can launch any application he desires. The email generates the charbuffer.

    Code:
    char *pathpointer;
    static char Temp[TEMP_SIZE];

    ///search string to see if an Execute email recieved?
    if (strstr(Temp,"Execute") !=NULL)
    {
    ////get a pointer to the location of the app to execute
    pathpointer=strstr(Temp,"Execute")+8;
    hInst = ShellExecute(0,"open",pathpointer,0,0,SW_SHOW);
    }





    If i harcode the pathpointer and write: "c:\\winnt\\notepad.exe"
    it works fine, but If i store this string in the "Temp" buffer
    the string is found but ShelExecute doesnt find the executable.....

    Strangely if, I write a web adress like www.volvo.se , then ShellExecute launches the web browser as it is suppoes to.
    It seems to have something to do with either termination or the path.


    But I have tried to copy from the pointer to a new char buff, terminate it and then use it with ShellExecute, I have also tried the various path functions in API 32, but to no avail. And, as I said, when I hardcode the string, it works........

    Anyones suggestions is extremly appreciated!!!

    Henrik

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Don't cross-post!
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Insert a breakpoint right after the line that assigns data to pathpointer. Find out the actually string pathpointer points to.

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  3. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 02:40 AM
  4. Replies: 4
    Last Post: 03-03-2006, 01:11 AM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 02:23 PM

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