Click here to Skip to main content
15,916,527 members
Home / Discussions / C#
   

C#

 
AnswerRe: foreach statement Pin
Christian Graus24-Jun-08 16:16
protectorChristian Graus24-Jun-08 16:16 
GeneralRe: foreach statement Pin
twistz24-Jun-08 21:03
twistz24-Jun-08 21:03 
GeneralRe: foreach statement Pin
Christian Graus24-Jun-08 21:09
protectorChristian Graus24-Jun-08 21:09 
AnswerRe: foreach statement Pin
Mohammad Dayyan24-Jun-08 16:19
Mohammad Dayyan24-Jun-08 16:19 
GeneralRe: foreach statement Pin
PIEBALDconsult24-Jun-08 16:33
mvePIEBALDconsult24-Jun-08 16:33 
GeneralRe: foreach statement Pin
Ashfield24-Jun-08 21:19
Ashfield24-Jun-08 21:19 
GeneralRe: foreach statement Pin
Guffa24-Jun-08 21:59
Guffa24-Jun-08 21:59 
QuestionHow to transfer a custom struct pointer to DLL's function? Pin
samfromcn24-Jun-08 15:24
samfromcn24-Jun-08 15:24 
I has a C++ DLL, it has follow code:

typedef struct _SC_CONTEXT{
long hPort;
long dwCardType;
// BYTE params[24];
} SC_CONTEXT;

extern int __stdcall TestFunc(SC_CONTEXT* p)
{
char buf[256];
sprintf(buf, "hPort is : %d, dwCardType is : %d.", p.hPort, p.dwCardType);
// sprintf(buf, "hPort is : %d, dwCardType is : %d, params[0] is : %d.", p->hPort, p->dwCardType, p->params[0]);
MessageBoxA(NULL, buf, "caption1", MB_OK);
return 0;
}

I wrote C# code like :

[StructLayout(LayoutKind.Sequential)]
public struct _SC_CONTEXT
{
public long hPort;
public long dwCardType;
}

namespace MyName
{
class MyClass
{
[DllImport("testDll.dll")]
public static extern int TestFunc(ref _SC_CONTEXT11 a);
}
static void Main(string[] args)
{
unsafe
{
_SC_CONTEXT a;// = new _SC_CONTEXT();
a.hPort = 67;
a.dwCardType = 66;
// a.paras[0] = 255;
TestFunc(ref a);
}
......
}
}

the question is, function TestFunc can not get _SC_CONTEXT::dwCardType's value. In the messagebox, content always is "hPort is : 67, dwCardType is : 0.". I want to know why, and how to correct this bug. As you see, I comment an array member of the struct, if not comment it, how to use struct with array member.Confused | :confused:
AnswerRe: How to transfer a custom struct pointer to DLL's function? Pin
mav.northwind24-Jun-08 19:14
mav.northwind24-Jun-08 19:14 
GeneralRe: How to transfer a custom struct pointer to DLL's function? Pin
samfromcn24-Jun-08 20:19
samfromcn24-Jun-08 20:19 
QuestionAttributes and there constructors... Pin
Paw Jershauge24-Jun-08 12:04
Paw Jershauge24-Jun-08 12:04 
AnswerRe: Attributes and there constructors... Pin
Spacix One24-Jun-08 12:14
Spacix One24-Jun-08 12:14 
GeneralRe: Attributes and there constructors... Pin
Paw Jershauge24-Jun-08 12:21
Paw Jershauge24-Jun-08 12:21 
GeneralRe: Attributes and there constructors... Pin
Spacix One24-Jun-08 12:33
Spacix One24-Jun-08 12:33 
GeneralRe: Attributes and there constructors... Pin
Paw Jershauge25-Jun-08 11:38
Paw Jershauge25-Jun-08 11:38 
QuestionHow to read wav file from a xml file in C# Pin
Member 470467524-Jun-08 11:09
Member 470467524-Jun-08 11:09 
AnswerRe: How to read wav file from a xml file in C# Pin
Spacix One24-Jun-08 11:27
Spacix One24-Jun-08 11:27 
AnswerRe: How to read wav file from a xml file in C# Pin
Gurpreet11124-Jun-08 12:10
Gurpreet11124-Jun-08 12:10 
QuestionWebBrowser.Print Pin
TiredProgrammer24-Jun-08 10:20
TiredProgrammer24-Jun-08 10:20 
AnswerRe: WebBrowser.Print Pin
Spacix One24-Jun-08 11:26
Spacix One24-Jun-08 11:26 
QuestionAcceptSocket and ObjectDisposedException Pin
Anthony Mushrow24-Jun-08 9:27
professionalAnthony Mushrow24-Jun-08 9:27 
AnswerRe: AcceptSocket and ObjectDisposedException Pin
led mike24-Jun-08 9:38
led mike24-Jun-08 9:38 
GeneralRe: AcceptSocket and ObjectDisposedException Pin
Anthony Mushrow24-Jun-08 10:01
professionalAnthony Mushrow24-Jun-08 10:01 
GeneralRe: AcceptSocket and ObjectDisposedException Pin
led mike24-Jun-08 10:39
led mike24-Jun-08 10:39 
GeneralRe: AcceptSocket and ObjectDisposedException Pin
Anthony Mushrow24-Jun-08 10:43
professionalAnthony Mushrow24-Jun-08 10:43 

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.