Click here to Skip to main content
15,913,773 members
Home / Discussions / C#
   

C#

 
GeneralRe: Updating empty Database with DataSet? Pin
george ivanov16-Feb-06 20:38
george ivanov16-Feb-06 20:38 
QuestionPassing C# WMI results to a HTML control Pin
dastrong16-Feb-06 2:41
dastrong16-Feb-06 2:41 
QuestionScrolling objects Pin
Sasuko16-Feb-06 2:15
Sasuko16-Feb-06 2:15 
AnswerRe: Scrolling objects Pin
malharone16-Feb-06 3:48
malharone16-Feb-06 3:48 
GeneralRe: Scrolling objects Pin
Sasuko16-Feb-06 4:45
Sasuko16-Feb-06 4:45 
QuestionIs there any way to detect and stop/pause somebody logging off? Pin
Anthony Mushrow16-Feb-06 2:14
professionalAnthony Mushrow16-Feb-06 2:14 
AnswerRe: Is there any way to detect and stop/pause somebody logging off? Pin
KaptinKrunch16-Feb-06 14:48
KaptinKrunch16-Feb-06 14:48 
Questionhow to use COM interop in C# Pin
Nataraj197816-Feb-06 0:16
Nataraj197816-Feb-06 0:16 
I have a requirement to use a dll written in Visual C++ 6.0 in my C# application. In order to establish the link between my application and the dll, I have written a ATL COM Component in Visual C++.NET [visual studio .NET version 8]. This COM component is referenced in my C# application. The COM component statically links with the 6.0 dll.

I am facing problems in passing data from C# to the dll through the COM component.

Description:
1. The dll exposes a function as:
__declspec(dllexport) int __stdcall ProblemFunction(int param1, BYTE param2, BYTE param3, BYTE *param4, DWORD *param5);

2. In the COM wrapper component, I have declared an interface method as:
[id(25), helpstring("method ProblemFunc")] HRESULT ProblemFunc([in] SHORT param1, [in] BYTE param2, [in] BYTE param3, [in, out] BYTE* param4, [in, out] LONG* param5, [out, retval] BYTE* param6);

where, param6 is used to return the value returned by dll function to the C# client application.

The implementation of this interface function is given below:
STDMETHODIMP
Wrapper::ProblemFunc(SHORT param1, BYTE param2, BYTE param3, BYTE* param4, LONG* param5, BYTE* param6)
{
*param6 = ProblemFunction(param1, param2, param3, param4, (DWORD*)param5);
return S_OK;
}

3. In the C# client application, I am calling the COM function as:
byte returnValue = DllWrapperObject.ProblemFunc(value1, (byte)value2, (byte)value3, ref value4, ref value5);

Here, I am facing problems passing value4 and value5 because:
a. For value4 I need to pass a structure.
b. For value5 I need to pass the size of the structure being passed in value4.

The structure to be passed is as required by the dll. The C++ structure is:
typedef struct
{
DWORD var1;
DWORD var2;

struct
{
DWORD var3;
char var4[16];
DWORD var5;
} var6[3];
} TEST_STRUCT;

I wrote the structure's equivalent in C# as a class as I had to create an array. The C# implementation of the above given structure is:
internal class InnerStruct
{
long var3;
char[] var4 = new char[16];
long var5;

internal static int GetSizeOfClass()
{
return (sizeof(long) + sizeof(char) * 16 + sizeof(long));
}
}

internal class TestStruct
{
long var1;
long var2;
InnerStruct[] var6 = new InnerStruct[3];

internal static int GetSizeOfClass()
{
return (sizeof(long) * 2 + InnerStruct.GetSizeOfClass() * 3);
}
}


Questions:
1. Is there any better way to define the structure equivalent in C#?
2. How can I get the size of the structure/class for passing it to the dll?
3. How to pass the handle of the structure/class object from C# to the dll so that it can fill it up and return it to the client app for future usage?
AnswerRe: how to use COM interop in C# Pin
Andy Moore16-Feb-06 3:36
Andy Moore16-Feb-06 3:36 
GeneralRe: how to use COM interop in C# Pin
Nataraj197816-Feb-06 18:11
Nataraj197816-Feb-06 18:11 
GeneralRe: how to use COM interop in C# Pin
Andy Moore17-Feb-06 3:23
Andy Moore17-Feb-06 3:23 
Question[Message Deleted] Pin
Michiel_NL15-Feb-06 23:41
Michiel_NL15-Feb-06 23:41 
AnswerRe: C# Excel. Process doesn't kill. Pin
Curtis Schlak.16-Feb-06 3:17
Curtis Schlak.16-Feb-06 3:17 
QuestionChange IP Address Pin
am2h15-Feb-06 23:23
am2h15-Feb-06 23:23 
AnswerRe: Change IP Address Pin
J4amieC16-Feb-06 0:16
J4amieC16-Feb-06 0:16 
GeneralRe: Change IP Address Pin
am2h17-Feb-06 20:36
am2h17-Feb-06 20:36 
AnswerRe: Change IP Address Pin
leppie16-Feb-06 3:01
leppie16-Feb-06 3:01 
GeneralRe: Change IP Address Pin
am2h17-Feb-06 20:34
am2h17-Feb-06 20:34 
QuestionHow To inject Process in c# ? Pin
hdv21215-Feb-06 23:18
hdv21215-Feb-06 23:18 
AnswerRe: How To inject Process in c# ? Pin
leppie16-Feb-06 0:13
leppie16-Feb-06 0:13 
AnswerRe: How To inject Process in c# ? Pin
J. Dunlap16-Feb-06 0:20
J. Dunlap16-Feb-06 0:20 
QuestionGet full SOAP message Pin
Nandiator15-Feb-06 22:10
Nandiator15-Feb-06 22:10 
AnswerRe: Get full SOAP message Pin
J4amieC15-Feb-06 22:25
J4amieC15-Feb-06 22:25 
AnswerRe: Get full SOAP message Pin
Maqsood Ahmed15-Feb-06 22:26
Maqsood Ahmed15-Feb-06 22:26 
QuestionImages Pin
albCode15-Feb-06 21:39
albCode15-Feb-06 21:39 

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.