#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    101
    Rep Power
    0

    Execle function runs right or not?


    I couldn't find any references to my problem, this was the closest I found.

    The envp[] array is a pointer to all of the UNIX environment variables for the process to be created. That defines the "environment" for the new process
    ~http://stackoverflow.com/questions/16864812/execle-also-specifies-the-environment-what-does-that-mean
    that's what I'm trying to do here except on a Windows platform.

    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<process.h>
    
    int main()
    {
    	char *env[] = {"Director=CommonProgramFiles",NULL};
    	execle("C:\\Program Files (x86)\\Movie Maker 2.6\\MOVIEMK.exe","C:\\Program Files (x86)\\Movie Maker 2.6\\MOVIEMK.exe",NULL,env);
    	printf("%s",getenv("C:\\Program Files (x86)\\Movie Maker 2.6\\MOVIEMK.exe"));
    	getchar();
    	return 0;
    }
    This opens up windows movie maker but I can't tell if it moves into the environment I called, CommonProgramFiles (an environment variable that's on my system.) I look to see if windows movie maker is in that file and it's not. I try to print to see what's its environment variable and I get NULL. What's the correct way of passing an environment variable to an executable file?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0
    Since you're using Windows, You might have better luck with CreateProcess. One of the parameters allows you to specify an environment block.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    101
    Rep Power
    0
    Yeah ok. But this computer is almost trashed and I'm turning into getting another computer soon. Hopefully Linux if my dad lets me. Anyway is this code right?
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    101
    Rep Power
    0
    By the way do you think using the spawn function(s) suitable enough? It's just like the exec functions and is simple to use. createprocess and shellexecute have all these arguments.

IMN logo majestic logo threadwatch logo seochat tools logo