Click here to Skip to main content
15,905,316 members
Home / Discussions / C#
   

C#

 
GeneralRe: validation of class attributes Pin
devvvy8-Dec-08 17:11
devvvy8-Dec-08 17:11 
GeneralRe: validation of class attributes Pin
N a v a n e e t h8-Dec-08 19:58
N a v a n e e t h8-Dec-08 19:58 
Questionderived class to automatically call base method before "return" Pin
devvvy8-Dec-08 13:56
devvvy8-Dec-08 13:56 
AnswerRe: derived class to automatically call base method before "return" Pin
PIEBALDconsult8-Dec-08 14:12
mvePIEBALDconsult8-Dec-08 14:12 
AnswerRe: derived class to automatically call base method before "return" Pin
Christian Graus8-Dec-08 14:14
protectorChristian Graus8-Dec-08 14:14 
AnswerRe: derived class to automatically call base method before "return" Pin
Thomas Weller9-Dec-08 3:12
Thomas Weller9-Dec-08 3:12 
QuestionHow can I get "Struct's address"~ help me~ Pin
G.I Cho8-Dec-08 13:03
G.I Cho8-Dec-08 13:03 
GeneralRe: How can I get "Struct's address"~ help me~ Pin
Luc Pattyn8-Dec-08 13:24
sitebuilderLuc Pattyn8-Dec-08 13:24 
Hi,

you don't need unsafe to use P/Invoke.

What you should do is use the GCHandle class to pin objects (so the GC won't move them around),
then obtain their address, pass that as an IntPtr, and afterwards free the handle.
You don't need to do this for strings though: a read-only string can be passed as is, and your C code will get a valid char*. For a writable string, use a StringBuilder instead.

Make sure you describe the structs correctly; be careful with the size of simple types,
long in C# is 64-bit, in most C environments it is 32-bit; and char in C# is 16-bit, in C it is 8-bit. Also be careful with alignment, the byte stuffing rules could be different on both sides.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

Fixturized forever. Confused | :confused:


GeneralRe: How can I get "Struct's address"~ help me~ Pin
G.I Cho8-Dec-08 18:39
G.I Cho8-Dec-08 18:39 
Questionembed .net component to program Pin
saeed70078-Dec-08 11:11
saeed70078-Dec-08 11:11 
AnswerRe: embed .net component to program Pin
EliottA8-Dec-08 11:28
EliottA8-Dec-08 11:28 
AnswerRe: embed .net component to program Pin
Giorgi Dalakishvili8-Dec-08 19:26
mentorGiorgi Dalakishvili8-Dec-08 19:26 
AnswerRe: embed .net component to program Pin
Lev Danielyan8-Dec-08 19:55
Lev Danielyan8-Dec-08 19:55 
QuestionHow to update my datagrid using text boxes? Pin
Vloops8-Dec-08 11:11
Vloops8-Dec-08 11:11 
AnswerRe: How to update my datagrid using text boxes? Pin
Alireza Loghmani8-Dec-08 22:40
Alireza Loghmani8-Dec-08 22:40 
QuestionThrottling Socket.Send Pin
davidhart8-Dec-08 10:13
davidhart8-Dec-08 10:13 
AnswerRe: Throttling Socket.Send Pin
Jimmanuel8-Dec-08 11:19
Jimmanuel8-Dec-08 11:19 
QuestionDrawing a window overlay Pin
xxxsamixxx8-Dec-08 10:08
xxxsamixxx8-Dec-08 10:08 
QuestionMeasuring reaction time of the user. Pin
Jakob Olsen8-Dec-08 9:49
Jakob Olsen8-Dec-08 9:49 
AnswerRe: Measuring reaction time of the user. Pin
User 66588-Dec-08 9:57
User 66588-Dec-08 9:57 
GeneralRe: Measuring reaction time of the user. Pin
Jakob Olsen8-Dec-08 10:20
Jakob Olsen8-Dec-08 10:20 
QuestionAdd image to spreadsheetml document Pin
GibbleCH8-Dec-08 9:48
GibbleCH8-Dec-08 9:48 
QuestionAcquiring a thread. Pin
Member 23244838-Dec-08 9:22
Member 23244838-Dec-08 9:22 
AnswerRe: Acquiring a thread. Pin
Christian Graus8-Dec-08 9:45
protectorChristian Graus8-Dec-08 9:45 
GeneralRe: Acquiring a thread. Pin
Member 23244838-Dec-08 10:20
Member 23244838-Dec-08 10:20 

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.