Click here to Skip to main content
15,914,111 members
Home / Discussions / C#
   

C#

 
GeneralRe: trim problems Pin
asugix3-Feb-09 19:36
asugix3-Feb-09 19:36 
QuestionTCP-IP Pin
Mr.Khan,Firoz28-Jan-09 18:29
Mr.Khan,Firoz28-Jan-09 18:29 
AnswerRe: TCP-IP Pin
SeMartens28-Jan-09 21:27
SeMartens28-Jan-09 21:27 
QuestionCahcing Open Source for C# Pin
Member 587250028-Jan-09 18:02
Member 587250028-Jan-09 18:02 
QuestionPublic Queue in Remote Machine in the same domain and network Pin
M. J. Jaya Chitra28-Jan-09 17:50
M. J. Jaya Chitra28-Jan-09 17:50 
Questiondifference between listbox.selecteditem and listbox.selectedvalue Pin
shining28-Jan-09 17:10
shining28-Jan-09 17:10 
AnswerRe: difference between listbox.selecteditem and listbox.selectedvalue Pin
Ravi Bhavnani28-Jan-09 17:36
professionalRavi Bhavnani28-Jan-09 17:36 
QuestionC# to C++ Interop issues Pin
AnnDunbar28-Jan-09 11:20
AnnDunbar28-Jan-09 11:20 
I am creating a DLL wrapper for some old C++ libs so they can be used by C#. I have a communication structure that is allocated by the C++ functions and returned to C#, C# needs to fill in some data and pass it back into the C++ code.
I have it working but its nasty code - hoping someone will have a better idea.

C++ structure
typedef struct
{ uint32 qRequest; // set to desired operation
uint32 qStatus; // server to sets to status
uint32 qReqBufSize; // total size of buffer
uint32 qReqBufValidLen; // amount of valid data
char acReqBuf[1]; // request data buffer
// allocated for qReqBufSize bytes
} myREQUEST;

C# struct
[StructLayout(LayoutKind.Sequential, Pack=1) ]
public struct myREQUEST_CS
{
[MarshalAs(UnmanagedType.U4)] public uint Req; // set to desired operation
[MarshalAs(UnmanagedType.U4)] public uint Stat; // server to sets to status
[MarshalAs(UnmanagedType.U4)] public uint ReqBufSize; // total size of buffer
[MarshalAs(UnmanagedType.U4)] public uint ReqBufValidLen; // amount of valid data
// hardcoded for size for now
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 296)]
public char[] ReqBuf;
}

My big problem is the Buffer (ReqBuf) area in the Struct. This is allocated as contiguous memory chunk with the Struct. It is just a place holder that in C++ gets cast to another structure. I need to read and write to this area in C#.

I've been using combinations of Marshal.AllocHGlobal(), Marshal.StructureToPtr and Marshal.PtrToStructure - just hoping someone knows of a better way to access and write to the ReqBuf area of my structure
AnswerRe: C# to C++ Interop issues [modified] Pin
Luc Pattyn28-Jan-09 11:30
sitebuilderLuc Pattyn28-Jan-09 11:30 
QuestionConvert .flv to .WMV/.WMA/.MPEG file using C#? Pin
pankazmittal28-Jan-09 11:00
pankazmittal28-Jan-09 11:00 
AnswerRe: Convert .flv to .WMV/.WMA/.MPEG file using C#? Pin
Thomas Stockwell28-Jan-09 11:59
professionalThomas Stockwell28-Jan-09 11:59 
QuestionNewbie Question Pin
kruegersck28-Jan-09 10:19
kruegersck28-Jan-09 10:19 
AnswerRe: Newbie Question Pin
DaveyM6928-Jan-09 10:40
professionalDaveyM6928-Jan-09 10:40 
QuestionSendmessage to MSN Live window [modified] Pin
Schoolmelk28-Jan-09 8:33
Schoolmelk28-Jan-09 8:33 
AnswerRe: Sendmessage to MSN Live window Pin
Ravi Bhavnani28-Jan-09 17:39
professionalRavi Bhavnani28-Jan-09 17:39 
GeneralRe: Sendmessage to MSN Live window Pin
Schoolmelk28-Jan-09 19:50
Schoolmelk28-Jan-09 19:50 
GeneralRe: Sendmessage to MSN Live window Pin
Ravi Bhavnani29-Jan-09 2:38
professionalRavi Bhavnani29-Jan-09 2:38 
GeneralRe: Sendmessage to MSN Live window Pin
Schoolmelk29-Jan-09 4:04
Schoolmelk29-Jan-09 4:04 
GeneralRe: Sendmessage to MSN Live window Pin
Ravi Bhavnani29-Jan-09 5:56
professionalRavi Bhavnani29-Jan-09 5:56 
GeneralRe: Sendmessage to MSN Live window Pin
Schoolmelk29-Jan-09 6:05
Schoolmelk29-Jan-09 6:05 
QuestionProperties [modified] Pin
CodingYoshi28-Jan-09 7:56
CodingYoshi28-Jan-09 7:56 
AnswerRe: Properties Pin
Wendelius28-Jan-09 8:01
mentorWendelius28-Jan-09 8:01 
GeneralRe: Properties Pin
CodingYoshi28-Jan-09 8:04
CodingYoshi28-Jan-09 8:04 
GeneralRe: Properties Pin
Wendelius28-Jan-09 8:10
mentorWendelius28-Jan-09 8:10 
GeneralRe: Properties Pin
CodingYoshi28-Jan-09 8:19
CodingYoshi28-Jan-09 8: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.