Advertisement

04.12.2007 at 10:11PM PDT, ID: 22509005
[x]
Attachment Details

DLL - string to char* problems

Asked by jazduck in C++ Programming Language, Windows Programming, Miscellaneous Programming

Tags: string, dll, memory

I have a problem with some code, hoping someone can help me, the idea of the code is to start a process, and block all code execution until that process has terminated.

The following function works as a Win32 Application, it doesn't work when compiled to a DLL and gives the error message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." (Called using VS.NET 2005, C#).

Now the problem is somewhere in the conversion from string to char* which the CreateProcess API accepts, if I accept a char[] the code executes as a DLL just fine, unfortunatly I have little choice in the matter, and have to get it working with a string.

Help would be most appreciated.

void StartProcess(string path)
{
      STARTUPINFO          si = { sizeof(si) };
      PROCESS_INFORMATION  pi;

      if(CreateProcess(0, (char*)path.c_str(), 0, 0, FALSE, 0, 0, 0, &si, &pi))
      {         
         WaitForSingleObject(pi.hProcess, INFINITE);

         CloseHandle(pi.hProcess);
         CloseHandle(pi.hThread);
      }      
}Start Free Trial
 
Keywords: DLL - string to char* problems
 
Loading Advertisement...
 
[+][-]04.13.2007 at 12:16AM PDT, ID: 18903849

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.13.2007 at 01:24AM PDT, ID: 18904036

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.13.2007 at 01:55AM PDT, ID: 18904140

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C++ Programming Language, Windows Programming, Miscellaneous Programming
Tags: string, dll, memory
Sign Up Now!
Solution Provided By: itsmeandnobodyelse
Participating Experts: 4
Solution Grade: A
 
 
[+][-]04.13.2007 at 02:22AM PDT, ID: 18904236

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.13.2007 at 03:25AM PDT, ID: 18904418

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.13.2007 at 04:08AM PDT, ID: 18904567

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.13.2007 at 05:08AM PDT, ID: 18904777

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.13.2007 at 06:16AM PDT, ID: 18905078

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.13.2007 at 10:21AM PDT, ID: 18907127

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.13.2007 at 02:10PM PDT, ID: 18908537

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.13.2007 at 06:35PM PDT, ID: 18909406

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.15.2007 at 10:40PM PDT, ID: 18916031

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32