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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to Set the environment using CreateProcess

How to Set the environment using CreateProcess

Scheduled Pinned Locked Moved C / C++ / MFC
helpvisual-studiojsontutorialquestion
2 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.
  • V Offline
    V Offline
    vipin_nvk
    wrote on last edited by
    #1

    Hi My application (say App.exe) is supposed to be launched by another process called Laucher.exe since some environment variables are needed to be set for App.exe to run. I am using CreateProcess API in Launcher.exe to set the necessary environment variables. I had written a sample earlier where in both by Launcher.exe and App.exe were non-unicode (built in VC 6.0). But, currently I have moved to VS 2008 which where in the application comes with unicode settings by default. I have converted both Launcher.exe and App.exe to Unicode, but I am having a problem to use CreateProcess in Launcher.exe to launch App.exe Since my App.exe is in unicode I think we have to set the lpEnvironment (in CreateProcess to CREATE_UNICODE_ENVIRONMENT flag) But just setting this and using the API the same way fails to launch my App.exe. I could not find sufficient links on the internet which explain how to use this flag and launch the application in a unicode environment Can somebody help me out if you have used this in advance? Thanx Vipin

    _ 1 Reply Last reply
    0
    • V vipin_nvk

      Hi My application (say App.exe) is supposed to be launched by another process called Laucher.exe since some environment variables are needed to be set for App.exe to run. I am using CreateProcess API in Launcher.exe to set the necessary environment variables. I had written a sample earlier where in both by Launcher.exe and App.exe were non-unicode (built in VC 6.0). But, currently I have moved to VS 2008 which where in the application comes with unicode settings by default. I have converted both Launcher.exe and App.exe to Unicode, but I am having a problem to use CreateProcess in Launcher.exe to launch App.exe Since my App.exe is in unicode I think we have to set the lpEnvironment (in CreateProcess to CREATE_UNICODE_ENVIRONMENT flag) But just setting this and using the API the same way fails to launch my App.exe. I could not find sufficient links on the internet which explain how to use this flag and launch the application in a unicode environment Can somebody help me out if you have used this in advance? Thanx Vipin

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      After reading your question, I'm guessing your real problem is that CreateProcess API is failing in UNICODE builds. And that in the earlier NON_UNICODE builds it was successful. If so, your title is very misleading. Actually there is a difference in how you would call CreateProcess in UNICODE and NON-UNICODE builds. In UNICODE builds, the lpCommandLine parameter of CreateProcess cannot be a constant because it will be modified internally. So you need to pass in a non-constant buffer here. This is documented in MSDN, but you would need to read it properly, which most of us do not do. :)

      «_Superman_»

      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