#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    London
    Posts
    13
    Rep Power
    0

    convert AnsiString to Char


    hi guys I am trying to run a file setup.exe, I have got the path for it in AnsiString DrivePath but the execinfo.lpFile does not take AnsiString value.

    Please suggest what shouldI do. :confused: :confused:



    AnsiString DriveInfo=ExtractFilePath(Application->ExeName)+"\\TMSlite\\setup.exe";

    SHELLEXECUTEINFO execinfo ;
    memset (&execinfo, 0, sizeof (execinfo)) ;
    execinfo.cbSize = sizeof (execinfo) ;
    execinfo.lpVerb = "open" ;
    execinfo.lpFile = VALUE_OF_DriveInfo;
    execinfo.fMask = SEE_MASK_NOCLOSEPROCESS ;
    execinfo.nShow = SW_SHOWDEFAULT ;
    ShellExecuteEx (&execinfo) ;
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,091
    Rep Power
    2222
    Check the documentation on AnsiString to see if it has a method for appearing to be a char array.

    If I am not mistaken (I don't use BCB), that method is called c_str(), just like in C++'s string class. But you should check the help files to verify that first.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    London
    Posts
    13
    Rep Power
    0
    Thanks a lot, did the trick for me.
    Here is the code to run an application within th application for others as well:
    if (RadioButton1->Checked)
    {
    AnsiString Path=ExtractFilePath(Application->ExeName)+"\\TMSlite\\setup";
    char *cp = Path.c_str();
    SHELLEXECUTEINFO execinfo ;
    memset (&execinfo, 0, sizeof (execinfo)) ;
    execinfo.cbSize = sizeof (execinfo) ;
    execinfo.lpVerb = "open" ;
    execinfo.lpFile = cp;
    execinfo.fMask = SEE_MASK_NOCLOSEPROCESS ;
    execinfo.nShow = SW_SHOWDEFAULT ;
    ShellExecuteEx (&execinfo) ;

IMN logo majestic logo threadwatch logo seochat tools logo