Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. How to execute another application

How to execute another application

Scheduled Pinned Locked Moved Managed C++/CLI
helpwinformstutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abbd
    wrote on last edited by
    #1

    I use Windows Forms Application and i would execute an another application like a Word file, i try ShellExecute; But there are errors, i write : ShellExecute(0,'OPEN','C:\Documents and Settings\abbd\Bureau\App2.0\Ids 0.0\Ids 0.0\az.doc',Nil,Nil, SW_SHOW); error C2015: too many characters in constant error C2065: 'Nil' : undeclared identifier error C2065: 'SW_SHOW' : undeclared identifier error C3861: 'ShellExecute': identifier not found Please help to execute this file, thank you.

    N L D 3 Replies Last reply
    0
    • A abbd

      I use Windows Forms Application and i would execute an another application like a Word file, i try ShellExecute; But there are errors, i write : ShellExecute(0,'OPEN','C:\Documents and Settings\abbd\Bureau\App2.0\Ids 0.0\Ids 0.0\az.doc',Nil,Nil, SW_SHOW); error C2015: too many characters in constant error C2065: 'Nil' : undeclared identifier error C2065: 'SW_SHOW' : undeclared identifier error C3861: 'ShellExecute': identifier not found Please help to execute this file, thank you.

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      Since you are using .NET, you should use Process::Start

      Regards, Nish


      Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
      Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*)

      1 Reply Last reply
      0
      • A abbd

        I use Windows Forms Application and i would execute an another application like a Word file, i try ShellExecute; But there are errors, i write : ShellExecute(0,'OPEN','C:\Documents and Settings\abbd\Bureau\App2.0\Ids 0.0\Ids 0.0\az.doc',Nil,Nil, SW_SHOW); error C2015: too many characters in constant error C2065: 'Nil' : undeclared identifier error C2065: 'SW_SHOW' : undeclared identifier error C3861: 'ShellExecute': identifier not found Please help to execute this file, thank you.

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        abbd wrote:

        error C3861: 'ShellExecute': identifier not found

        That error indicates you don't know how to #include header files for C++ development. The fact that you don't know that indicates that you need to step back to student mode and learn some prerequisite programming topics before you try to write working windows applications.

        led mike

        1 Reply Last reply
        0
        • A abbd

          I use Windows Forms Application and i would execute an another application like a Word file, i try ShellExecute; But there are errors, i write : ShellExecute(0,'OPEN','C:\Documents and Settings\abbd\Bureau\App2.0\Ids 0.0\Ids 0.0\az.doc',Nil,Nil, SW_SHOW); error C2015: too many characters in constant error C2065: 'Nil' : undeclared identifier error C2065: 'SW_SHOW' : undeclared identifier error C3861: 'ShellExecute': identifier not found Please help to execute this file, thank you.

          D Offline
          D Offline
          darkcloud 42o
          wrote on last edited by
          #4

          first of all the type of formas application you need is.... CLR Windows Forms Aplication create a process outside the namespace.. and use these headers.. #include string #include windows.h #include process.h using namespace std; unsigned __stdcall execplz(void *params); string cl; somewhere in your program you need to place the following line to execute the command; unsigned sID; (HANDLE)_beginthreadex( NULL, 0, execplz, NULL, 0, &sID); and keep in mind the command line string is std::string cl; which i have set as global string at top so you can use anywhere.. the process below will create a process invisibly to yours ok.. so to change that you need to remove... si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; unsigned __stdcall execplz(void *params){ string fnn; int nLen = cl.length(); bl=cl; std::string::size_type idx; idx=bl.rfind("\\"); bl=bl.substr(idx, string::npos); cl=cl.substr(0, idx-1); int nLeng = bl.length(); LPWSTR szCmdLine = new WCHAR[nLen+1]; MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,cl.c_str(),nLen,szCmdLine,nLen); szCmdLine[nLen] = '\0'; LPWSTR fnonly = new WCHAR[nLeng+1]; MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,bl.c_str(),nLeng,fnonly,nLeng); fnonly[nLeng]='\0'; STARTUPINFO si; PROCESS_INFORMATION pi; GetStartupInfo(&si); si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); if( !CreateProcess( szCmdLine, fnonly, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) ) { printf( "CreateProcess failed (%d).\n", GetLastError() ); } return 0; } ok so the reason why i have this a separate process.. is because its using threads.. you can use this at anytime even when soemthing else is going on..multiple times at once if wished.. good for creating webservers and such... -- modified at 5:26 Saturday 10th March, 2007

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups