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

C#

 
QuestionSearching in XML Pin
zeeShan anSari13-Jul-09 7:56
zeeShan anSari13-Jul-09 7:56 
AnswerRe: Searching in XML Pin
PIEBALDconsult13-Jul-09 8:18
mvePIEBALDconsult13-Jul-09 8:18 
AnswerRe: Searching in XML Pin
Not Active13-Jul-09 8:19
mentorNot Active13-Jul-09 8:19 
AnswerRe: Searching in XML Pin
0x3c013-Jul-09 8:43
0x3c013-Jul-09 8:43 
GeneralRe: Searching in XML Pin
Not Active13-Jul-09 10:19
mentorNot Active13-Jul-09 10:19 
GeneralRe: Searching in XML Pin
0x3c013-Jul-09 19:54
0x3c013-Jul-09 19:54 
QuestionUnmanaged DLL: C# variable for C++ char** Pin
belier113-Jul-09 7:06
belier113-Jul-09 7:06 
AnswerRe: Unmanaged DLL: C# variable for C++ char** Pin
Luc Pattyn13-Jul-09 7:28
sitebuilderLuc Pattyn13-Jul-09 7:28 
Hi,

when mixing managed code and unmanaged/native code, I recommend you let the managed side do the array allocations (so they are real objects); doing so, all you need is one of two things:

1. the fixed keyword, which is OK if the array is used natively only while the native function executes; here the P/Invoke prototype takes a pointer where the native code expects a pointer.

2. the GCHandle class, which allows you to:
- pin the object, so the GC can no longer move it around
- get a pointer to it
- pass that pointer to the native function
- when done, free the GCHandle object.
Here the P/Invoke prototype takes an IntPtr where the native code expects a pointer.

BTW: for strings, there are easy shortcuts:
- read-only strings can be passed as string and accepted as char*
- read/write strings can be passed as StringBuilder (call ToString when done)

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

GeneralRe: Unmanaged DLL: C# variable for C++ char** Pin
belier113-Jul-09 9:47
belier113-Jul-09 9:47 
GeneralRe: Unmanaged DLL: C# variable for C++ char** Pin
Luc Pattyn13-Jul-09 10:04
sitebuilderLuc Pattyn13-Jul-09 10:04 
GeneralRe: Unmanaged DLL: C# variable for C++ char** Pin
belier113-Jul-09 11:07
belier113-Jul-09 11:07 
GeneralRe: Unmanaged DLL: C# variable for C++ char** Pin
Luc Pattyn13-Jul-09 11:12
sitebuilderLuc Pattyn13-Jul-09 11:12 
GeneralRe: Unmanaged DLL: C# variable for C++ char** Pin
belier114-Jul-09 1:10
belier114-Jul-09 1:10 
QuestionGet local groups and users from server remotely with console app Pin
briancollins3213-Jul-09 6:50
briancollins3213-Jul-09 6:50 
QuestionHow do you count the number of decimals in a decimal datatype Pin
Nathan Revka13-Jul-09 6:26
Nathan Revka13-Jul-09 6:26 
AnswerRe: How do you count the number of decimals in a decimal datatype Pin
Luc Pattyn13-Jul-09 6:34
sitebuilderLuc Pattyn13-Jul-09 6:34 
AnswerRe: How do you count the number of decimals in a decimal datatype Pin
musefan13-Jul-09 6:51
musefan13-Jul-09 6:51 
AnswerRe: How do you count the number of decimals in a decimal datatype Pin
TheGreatAndPowerfulOz13-Jul-09 6:51
TheGreatAndPowerfulOz13-Jul-09 6:51 
QuestionDccg Pin
peishen8813-Jul-09 5:47
peishen8813-Jul-09 5:47 
AnswerRe: Dccg Pin
Luc Pattyn13-Jul-09 5:54
sitebuilderLuc Pattyn13-Jul-09 5:54 
GeneralRe: Dccg Pin
DoctorMick13-Jul-09 5:58
DoctorMick13-Jul-09 5:58 
GeneralRe: Dccg Pin
peishen8813-Jul-09 6:10
peishen8813-Jul-09 6:10 
GeneralRe: Dccg Pin
Luc Pattyn13-Jul-09 6:33
sitebuilderLuc Pattyn13-Jul-09 6:33 
QuestionHorizontal scrollbar broken in datagrid after migrating to VS2008 Pin
smcirish13-Jul-09 4:47
smcirish13-Jul-09 4:47 
Question2 dimensional byte array Pin
Vivek Vijayan13-Jul-09 4:19
Vivek Vijayan13-Jul-09 4:19 

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.