Thread: ShellExecute() string problem

  1. #1
    Registered User
    Join Date
    May 2003

    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.

    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
    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 , 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!!!


  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Don't cross-post!

    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
    Insert a breakpoint right after the line that assigns data to pathpointer. Find out the actually string pathpointer points to.


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, 03:40 AM
  4. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM