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. C / C++ / MFC
  4. Getting the hStdOutput from CreateProcess.hStdOutput [modified]

Getting the hStdOutput from CreateProcess.hStdOutput [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 Posts 2 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.
  • D Offline
    D Offline
    darkcloud 42o
    wrote on last edited by
    #1

    Hi, Having some trouble getting a char* from the Stupinfo.hStdOutput which is a HANDLE. STARTUPINFO Stupinfo; PROCESS_INFORMATION ProcessInfo; char* procnm="Test.exe"; HANDLE h; LPWSTR lpwString = L""; lpwString = (LPWSTR)procnm; IntPtr StdOutput; Stupinfo.dwX=0; Stupinfo.dwY=0; Stupinfo.hStdOutput=h; CreateProcess(NULL, lpwString, NULL, NULL, FALSE, 0, NULL, NULL, &Stupinfo, &ProcessInfo); char* tesst="test"; tesst=Stupinfo.hStdOutput; send(AcceptSocket, tesst, strlen(tesst), 0); I know its not going to be easy unless there is simple convesion. but ive seen methods which output to .txt file for some reason.. but i dont see why you couldn't get the char* Please Help -- modified at 17:31 Monday 31st July, 2006

    J 1 Reply Last reply
    0
    • D darkcloud 42o

      Hi, Having some trouble getting a char* from the Stupinfo.hStdOutput which is a HANDLE. STARTUPINFO Stupinfo; PROCESS_INFORMATION ProcessInfo; char* procnm="Test.exe"; HANDLE h; LPWSTR lpwString = L""; lpwString = (LPWSTR)procnm; IntPtr StdOutput; Stupinfo.dwX=0; Stupinfo.dwY=0; Stupinfo.hStdOutput=h; CreateProcess(NULL, lpwString, NULL, NULL, FALSE, 0, NULL, NULL, &Stupinfo, &ProcessInfo); char* tesst="test"; tesst=Stupinfo.hStdOutput; send(AcceptSocket, tesst, strlen(tesst), 0); I know its not going to be easy unless there is simple convesion. but ive seen methods which output to .txt file for some reason.. but i dont see why you couldn't get the char* Please Help -- modified at 17:31 Monday 31st July, 2006

      J Offline
      J Offline
      James Brown
      wrote on last edited by
      #2

      You have to create a HANDLE *before* calling CreateProcess. Usually people use CreatePipe, but you can also pass socket handles as well. Then you ReadFile/WriteFile to the handle to read/write data.


      http://www.catch22.net

      D 1 Reply Last reply
      0
      • J James Brown

        You have to create a HANDLE *before* calling CreateProcess. Usually people use CreatePipe, but you can also pass socket handles as well. Then you ReadFile/WriteFile to the handle to read/write data.


        http://www.catch22.net

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

        Could you please show me some code? STARTUPINFO Stupinfo; PROCESS_INFORMATION ProcessInfo; char* procnm="Test.exe"; char* tesst; BOOL readIntoMemory; HANDLE h, hWritePipe; LPSECURITY_ATTRIBUTES lpPipeAttributes; DWORD nSize; LPWSTR lpwString = L""; lpwString = (LPWSTR)procnm; LPVOID inBuffer; DWORD nBytesToRead; LPDWORD nBytesRead, lpNumberOfBytesWritten; DWORD bytestowrite; IntPtr StdOutput; Stupinfo.dwX=0; Stupinfo.dwY=0; Stupinfo.hStdOutput=h; CreateProcess(NULL, lpwString, NULL, NULL, FALSE, 0, NULL, NULL, &Stupinfo, &ProcessInfo); ReadFile( h, inBuffer, nBytesToRead, nBytesRead, NULL); WriteFile( (HANDLE)AcceptSocket, inBuffer, bytestowrite, lpNumberOfBytesWritten, NULL); how to use the WriteFile to get a char*?? and do i have it setup correctly? -- modified at 19:25 Monday 31st July, 2006

        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