Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
GeneralRe: Does anyone know of an recommending tool... Pin
Paw Jershauge28-Sep-09 22:01
Paw Jershauge28-Sep-09 22:01 
QuestionMarshaling between managed and unmanaged [modified] Pin
akhanal28-Sep-09 6:47
akhanal28-Sep-09 6:47 
AnswerRe: Marshaling between managed and unmanaged Pin
Luc Pattyn28-Sep-09 7:45
sitebuilderLuc Pattyn28-Sep-09 7:45 
GeneralRe: Marshaling between managed and unmanaged Pin
akhanal28-Sep-09 8:28
akhanal28-Sep-09 8:28 
GeneralRe: Marshaling between managed and unmanaged Pin
Luc Pattyn28-Sep-09 8:48
sitebuilderLuc Pattyn28-Sep-09 8:48 
GeneralRe: Marshaling between managed and unmanaged Pin
Richard MacCutchan28-Sep-09 9:16
mveRichard MacCutchan28-Sep-09 9:16 
GeneralRe: Marshaling between managed and unmanaged Pin
Luc Pattyn28-Sep-09 9:32
sitebuilderLuc Pattyn28-Sep-09 9:32 
GeneralRe: Marshaling between managed and unmanaged [modified] Pin
akhanal28-Sep-09 9:28
akhanal28-Sep-09 9:28 
I did as follows:

DllImport("SomeDLL.dll", EntryPoint = "func1")]
unsafe public static extern uint func1(UInt32 arg1, UInt32 arg2, ref IntPtr arg3);

And I am calling this function in my code as:

{
........
UInt32 arg1;
UInt32 arg2;

IntPtr arg3 = IntPtr.Zero; //made arg3 as Intptr
int [] managedArray = new int[1]; //created a managed array

uint test;

...........
test = func1(arg1, arg2, ref arg3);

............
/* I am using arg3 value over here*/
Marshal.Copy(arg3, managedArray, 0, 1);
if(managedArray[0] == null)
{
....
}
}

When I watch the managedArray[0] now, it still shows the values as before, kind of garbage values.

I am just writing a single value in the array (as indicated by the last param of Marshal.Copy because only one value is of interest).

Single indirection with out didn't help either.

modified on Monday, September 28, 2009 4:06 PM

GeneralRe: Marshaling between managed and unmanaged [modified] Pin
Luc Pattyn28-Sep-09 9:43
sitebuilderLuc Pattyn28-Sep-09 9:43 
GeneralRe: Marshaling between managed and unmanaged [modified] Pin
akhanal28-Sep-09 10:06
akhanal28-Sep-09 10:06 
GeneralRe: Marshaling between managed and unmanaged Pin
Luc Pattyn28-Sep-09 10:45
sitebuilderLuc Pattyn28-Sep-09 10:45 
GeneralRe: Marshaling between managed and unmanaged Pin
akhanal28-Sep-09 11:03
akhanal28-Sep-09 11:03 
GeneralRe: Marshaling between managed and unmanaged Pin
akhanal28-Sep-09 12:01
akhanal28-Sep-09 12:01 
GeneralRe: Marshaling between managed and unmanaged Pin
Luc Pattyn28-Sep-09 12:18
sitebuilderLuc Pattyn28-Sep-09 12:18 
GeneralRe: Marshaling between managed and unmanaged Pin
akhanal29-Sep-09 4:04
akhanal29-Sep-09 4:04 
GeneralRe: Marshaling between managed and unmanaged Pin
Luc Pattyn29-Sep-09 4:17
sitebuilderLuc Pattyn29-Sep-09 4:17 
GeneralRe: Marshaling between managed and unmanaged [modified] Pin
akhanal29-Sep-09 5:02
akhanal29-Sep-09 5:02 
GeneralRe: Marshaling between managed and unmanaged Pin
Luc Pattyn29-Sep-09 5:36
sitebuilderLuc Pattyn29-Sep-09 5:36 
GeneralRe: Marshaling between managed and unmanaged Pin
akhanal29-Sep-09 5:32
akhanal29-Sep-09 5:32 
GeneralRe: Marshaling between managed and unmanaged Pin
Luc Pattyn29-Sep-09 5:37
sitebuilderLuc Pattyn29-Sep-09 5:37 
GeneralRe: Marshaling between managed and unmanaged [modified] Pin
akhanal29-Sep-09 6:01
akhanal29-Sep-09 6:01 
GeneralRe: Marshaling between managed and unmanaged Pin
Luc Pattyn29-Sep-09 6:15
sitebuilderLuc Pattyn29-Sep-09 6:15 
GeneralRe: Marshaling between managed and unmanaged Pin
akhanal29-Sep-09 6:27
akhanal29-Sep-09 6:27 
QuestionGetting the selected items from a radioButton group Pin
Twyce28-Sep-09 6:42
Twyce28-Sep-09 6:42 
AnswerRe: Getting the selected items from a radioButton group Pin
Michael Eber28-Sep-09 7:04
Michael Eber28-Sep-09 7:04 

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.