CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: ShellExecute

  1. #1
    Join Date
    May 1999
    Location
    Bournemouth
    Posts
    2

    ShellExecute

    hi, im using BorlandC++Builder.. which im guessing is the same as the rest of the C++ family for the ShellExecute command..
    my problem is that the ShellExecute command requires a constant value to be entered... ie.. c:\\test.exe how would i declare a variable or item that could be placed within the ShellExecute command to run a file.. such as a value extracted from an ini file.

    Thanx a lot

    stuey


  2. #2
    Join Date
    Apr 1999
    Posts
    16

    Re: ShellExecute

    Using a string variable in the ShellExecute doesn't work? I don't believe it,just like following:
    char pszCh[30]="C:\\Windows\\Pbrush.exe";
    ShellExecute(NULL,"Open",pszCh,NULL,NULL,SW_SHOW);


  3. #3
    Guest

    Re: ShellExecute

    sprintf(var1,"%s+%s",var2,var3);
    sprintf(pFileTADDIR,"command.com /C T:\\%s\\upd",var1);
    if(!CreateProcess(NULL,pFileTADDIR,NULL,NULL,FALSE,
    CREATE_DEFAULT_ERROR_MODE, // creation flags
    NULL,NULL,&si,&pi ))





  4. #4
    Join Date
    Apr 1999
    Posts
    383

    Re: ShellExecute

    All the string arguments to ShellExecute are LPCTSTR, so you can pass char*, const char*, CString, TCHAR*, etc.

    A constant string argument does not mean a literal string argument, it just means the function contracts not to change the string. You can pass non-const strings if you want to.

    Here's a cutting from a working program:

    CString mode = GetExecuteMode();
    CString filePath = GetDocument()->GetFilePath();
    // [code removed]
    int result = (int)ShellExecute(AfxGetMainWnd()->GetSafeHwnd(), mode, filePath, 0, 0, SW_SHOWNORMAL);

    Dave


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

Featured