Click here to Skip to main content
15,896,606 members
Home / Discussions / C#
   

C#

 
GeneralC# Builder Pin
sreejith ss nair10-May-04 1:01
sreejith ss nair10-May-04 1:01 
GeneralRe: C# Builder Pin
Heath Stewart10-May-04 2:36
protectorHeath Stewart10-May-04 2:36 
QuestionHow to compare the file? Pin
m7779-May-04 22:37
m7779-May-04 22:37 
AnswerRe: How to compare the file? Pin
Heath Stewart10-May-04 2:52
protectorHeath Stewart10-May-04 2:52 
Questionhow to invoke API function which has pointer param ? Pin
fu09-May-04 21:58
fu09-May-04 21:58 
AnswerRe: how to invoke API function which has pointer param ? Pin
Mazdak9-May-04 22:41
Mazdak9-May-04 22:41 
AnswerRe: how to invoke API function which has pointer param ? Pin
Mazdak9-May-04 22:48
Mazdak9-May-04 22:48 
AnswerRe: how to invoke API function which has pointer param ? Pin
Heath Stewart10-May-04 3:04
protectorHeath Stewart10-May-04 3:04 
A pointer can always be declared as an IntPtr, but often times you really have to know the difference between value types and reference types. For a reference type, if you see an unmanaged declaration like ISomeInterface*, then you should (after declaring a managed interface named ISomeInterface just declare it as ISomeInterface. Interfaces are always reference types (a managed pointer) so the address is already passed. If you need to pass an array (like byte* or byte[], then just pass the array byte[]. An array is also a reference type, regardless of the element type. If you need to pass a reference to a struct (declared as SOMESTRUCT* in unmanaged code), then use either the out (for [out] declarations) or ref (for [in,out] declarations).

Also, while not required (in most cases) you should use the InAttribute and OutAttribute</copde> for parameters documented as [in] and [out], respectively. Many times you will also need to use the <code>MarshalAsAttribute to help the CLR determine how to marshal parameters across managed boundaries. See the documentation for those three aforementioned attributes in the .NET Framework SDK for more information.

There's also a topic in the .NET Framework SDK you should read, Platform Invoke Data Types[^], which have the type-maps for common unmanaged and managed types (like a common mistake is thinking a LONG in C/C++ is a long (Int64) in .NET; it's not - it's a 32-bit integer and hence an int (Int32).

 

Microsoft MVP, Visual C#
My Articles
AnswerRe: how to invoke API function which has pointer param ? Pin
fu011-May-04 17:24
fu011-May-04 17:24 
GeneralLogon Problem using DataSets with Crsytal Reports Pin
AAQ9-May-04 21:07
AAQ9-May-04 21:07 
GeneralRe: Logon Problem using DataSets with Crsytal Reports Pin
Mazdak9-May-04 21:49
Mazdak9-May-04 21:49 
Generalcreating a form at runtime Pin
cristina_tudor9-May-04 20:25
cristina_tudor9-May-04 20:25 
GeneralRe: creating a form at runtime Pin
Stefan Troschuetz9-May-04 21:18
Stefan Troschuetz9-May-04 21:18 
GeneralRe: creating a form at runtime Pin
Heath Stewart10-May-04 3:15
protectorHeath Stewart10-May-04 3:15 
GeneralSearching Text in a RichTextBox Pin
myNameIsRon9-May-04 19:09
myNameIsRon9-May-04 19:09 
GeneralRe: Searching Text in a RichTextBox Pin
Aryadip9-May-04 21:31
Aryadip9-May-04 21:31 
GeneralRe: Searching Text in a RichTextBox Pin
myNameIsRon10-May-04 13:50
myNameIsRon10-May-04 13:50 
QuestionNT / LM Hash? Pin
RhysMG9-May-04 18:43
RhysMG9-May-04 18:43 
AnswerRe: NT / LM Hash? Pin
Heath Stewart10-May-04 3:28
protectorHeath Stewart10-May-04 3:28 
GeneralRe: NT / LM Hash? Pin
10-May-04 10:27
suss10-May-04 10:27 
GeneralRe: NT / LM Hash? Pin
Heath Stewart10-May-04 10:48
protectorHeath Stewart10-May-04 10:48 
QuestionHow o change this code to C#? Pin
kookai9-May-04 18:17
kookai9-May-04 18:17 
AnswerRe: How o change this code to C#? Pin
Dave Kreskowiak10-May-04 0:38
mveDave Kreskowiak10-May-04 0:38 
GeneralDraw text on another app's DirectX window Pin
Darvus9-May-04 18:06
Darvus9-May-04 18:06 
QuestionInitialize control dropped on form? Pin
MilesAhead9-May-04 17:13
MilesAhead9-May-04 17:13 

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.