Click here to Skip to main content
15,895,656 members
Home / Discussions / C#
   

C#

 
GeneralTx for both answers Pin
Le centriste6-Jun-03 5:42
Le centriste6-Jun-03 5:42 
Generalxlat MFC to C# (Thread question) Pin
albean6-Jun-03 3:04
albean6-Jun-03 3:04 
GeneralTurn off computer Pin
yarns5-Jun-03 20:49
yarns5-Jun-03 20:49 
GeneralRe: Turn off computer Pin
J. Dunlap5-Jun-03 20:57
J. Dunlap5-Jun-03 20:57 
GeneralRe: Turn off computer Pin
Member 128221435-Jun-03 21:18
Member 128221435-Jun-03 21:18 
GeneralRe: Turn off computer Pin
Nathan Blomquist6-Jun-03 2:33
Nathan Blomquist6-Jun-03 2:33 
GeneralRe: Turn off computer Pin
Bo Hunter6-Jun-03 5:43
Bo Hunter6-Jun-03 5:43 
GeneralPassing array of strings to unmanaged code Pin
Anonymous5-Jun-03 20:03
Anonymous5-Jun-03 20:03 
Does anyone know how to pass an array of strings using unmanaged code? I'm attempting to use unmanaged code to execute an external application with arguments, for example:

c:\matlab\bin\matlab.exe arg1 arg2

The code works fine when arg1 is substitued for a single space character, and matlab executes as if no arguments were passed in. However when arg1 and arg2 are string objects (containing meaningful arguments) in an array of strings, an exception is raised, stating:

"Object reference not set to an instance of an object"

The code which makes the call to the unmanaged code is basically:

public class Win32Wrapper
{
[DllImport("PFA_Win32.dll", EntryPoint="RunExternalApplication", CharSet=CharSet.Ansi)]
private static extern int RunExternalApplication(String application, String[] arguments);

public int RunApplication(String application, String[] arguments)
{
int result = RunExternalApplication(application, arguments);

return result;
}
}


The unmanaged code, written in C++, looks something like:

extern "C" PFA_WIN32_API int __stdcall RunExternalApplication(const char *app, const char *const *argv)
{
return _spawnv(_P_NOWAIT, app, argv);
}


I'd be most appreciative if anyone has done anything similar to this, or can see any flaws in the code.

Thanks
Ash
GeneralMemory Usage...(RSS Bandit) Pin
Kant5-Jun-03 18:16
Kant5-Jun-03 18:16 
GeneralRe: Memory Usage...(RSS Bandit) Pin
Daniel Turini6-Jun-03 5:20
Daniel Turini6-Jun-03 5:20 
GeneralRe: Memory Usage...(RSS Bandit) (OT) Pin
Kannan Kalyanaraman6-Jun-03 5:37
Kannan Kalyanaraman6-Jun-03 5:37 
GeneralRe: Memory Usage...(RSS Bandit) (OT) Pin
shaunAustin6-Jun-03 12:13
shaunAustin6-Jun-03 12:13 
GeneralRe: Memory Usage...(RSS Bandit) (OT) Pin
Kannan Kalyanaraman7-Jun-03 23:56
Kannan Kalyanaraman7-Jun-03 23:56 
GeneralRe: Memory Usage...(RSS Bandit) (OT) Pin
Kant8-Jun-03 4:31
Kant8-Jun-03 4:31 
GeneralRe: Memory Usage...(RSS Bandit) (OT) Pin
Kannan Kalyanaraman8-Jun-03 22:18
Kannan Kalyanaraman8-Jun-03 22:18 
GeneralRe: Memory Usage...(RSS Bandit) (OT) Pin
James T. Johnson6-Jun-03 13:21
James T. Johnson6-Jun-03 13:21 
GeneralRe: Memory Usage...(RSS Bandit) (OT) Pin
Daniel Turini6-Jun-03 21:50
Daniel Turini6-Jun-03 21:50 
GeneralRe: Memory Usage...(RSS Bandit) (OT) Pin
Kannan Kalyanaraman7-Jun-03 23:44
Kannan Kalyanaraman7-Jun-03 23:44 
GeneralRe: Memory Usage...(RSS Bandit) Pin
Kant6-Jun-03 5:45
Kant6-Jun-03 5:45 
Generalimplementing interface not in same dir as class Pin
zuhx5-Jun-03 10:42
zuhx5-Jun-03 10:42 
GeneralRe: implementing interface not in same dir as class Pin
Bo Hunter5-Jun-03 17:03
Bo Hunter5-Jun-03 17:03 
GeneralRe: implementing interface not in same dir as class Pin
zuhx5-Jun-03 19:56
zuhx5-Jun-03 19:56 
GeneralRe: implementing interface not in same dir as class Pin
shaunAustin5-Jun-03 21:56
shaunAustin5-Jun-03 21:56 
GeneralRe: implementing interface not in same dir as class Pin
zuhx6-Jun-03 5:57
zuhx6-Jun-03 5:57 
GeneralRe: implementing interface not in same dir as class Pin
shaunAustin6-Jun-03 9:05
shaunAustin6-Jun-03 9:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.