c++ - How to call CreateProcess() in C# passing lpEnvironment -


i imported native createprocess c# project icordebug purposes http://msdn.microsoft.com/en-us/library/vstudio/ms232508(v=vs.100).aspx

 [methodimpl(methodimploptions.internalcall, methodcodetype = methodcodetype.runtime)]         void createprocess([in, marshalas(unmanagedtype.lpwstr)] string lpapplicationname, [in, marshalas(unmanagedtype.lpwstr)] string lpcommandline, [in] security_attributes lpprocessattributes, [in] security_attributes lpthreadattributes, [in] int binherithandles, [in] uint dwcreationflags, [in] intptr lpenvironment, [in, marshalas(unmanagedtype.lpwstr)] string lpcurrentdirectory, [in] startupinfo pstartupinfo, [in] process_information pprocessinformation, [in] cordebugcreateprocessflags debuggingflags, [marshalas(unmanagedtype.interface)] out icordebugprocess ppprocess); 

i call trying pass lpenvironment way

            intptr intptrenv;             if (variables != string.empty)                 intptrenv = marshal.stringtohglobaluni(variables);             else                 intptrenv = new intptr(0);   p_codebugger.createprocess(                                 exepath,                                 exepath,                                 null,                                 null,                                 1, // inherit handles                                 (uint32)createprocessflags.create_new_console,                                 intptrenv,                                 ".",                                 si,                                 pi,                                 cordebugcreateprocessflags.debug_no_special_options,                                 out proc); 

the variables string contains:

"cor_enable_profiling=1\0cor_profiler=profiler_guid\0cor_profiler_path=getprofilerfullpat\0\0" 

i error value exceeded allowable range

any suggestions how pass environment block c# c++ dll?

ok managed resolve problem. first used stringbuilder instead of intptr. add string "cor_enable_profiling=1\0cor_profiler=profiler_guid\0cor_profiler_path=getprofilerfullpat\0\0" add("cor_enable_profiling=1") , increse stringbuilder lenght + 1 etc...; end should incremented 1 more time lenght++ (this ansi encoding); second thing change , add marshalling imported method instead of [in] intptr lpenvironment add [in, marshalas(unmanagedtype.lpstr)] stringbuilder lpenvironment


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -