tags:

views:

250

answers:

2

Hi

iam using regasm.exe to generate tlb file and register the assembly programatically.But the path of tlb in .NET root directory itself. so do like this

buffer contains c:\windows\Microsoft.Net\framework\v2.0.57\RegAsm.exe

if(!CreateProcessW(buffer,L" C:\Program Files\Test\Test.dll /codebase /tlb /silent" ,NULL, NULL,FALSE, 0,NULL,NULL,(LPSTARTUPINFOW)&si,&pi ) )

But i think it wont tkae fulpath since there is a blank b/w Program and Files.as expected the when i run the command it also shows unable to locate input assembly c:\program.

normally at coomand prompt we can give as

RegAsm.exe "c:\program files\Test\test.dll" /codebase /tlb this bold characters i have to pass as command line but it have Double quptes with in double quotes. so i was strucked.

How can i fix it

A: 

Just see the documentation for the CreateProcess Function: http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx

It says:

lpCommandLine [in, out, optional] The Unicode version of this function, CreateProcessW, can modify the contents of this string. Therefore, this parameter cannot be a pointer to read-only memory (such as a const variable or a literal string). If this parameter is a constant string, the function may cause an access violation.

It has an example where one specifies an executable in "Program Files" Directory. . I am not that good in C++. Else would have given an example.

Ganesh R.
+1  A: 

You need to enclose the path in quotes within the string, which you can do by escaping the quote character by preceding it with a backslash. So, your 2nd parameter to CreateProcessW would be:

L"\"C:\Program Files\Test\Test.dll\" /codebase /tlb /silent"

This would give you the command line with quotes that you would use at the command prompt.

Steve Beedie