Click here to Skip to main content
15,903,856 members
Home / Discussions / C#
   

C#

 
AnswerRe: Multicolumn listbox in smart device application Pin
William Winner12-May-10 6:22
William Winner12-May-10 6:22 
Questionrole of substitution Pin
tek 200911-May-10 23:02
tek 200911-May-10 23:02 
AnswerRe: role of substitution Pin
Ravi Sant14-Apr-11 1:05
Ravi Sant14-Apr-11 1:05 
QuestionFree/Open Source Library to Generate Barcodes Pin
Rafferty Uy11-May-10 21:36
Rafferty Uy11-May-10 21:36 
AnswerRe: Free/Open Source Library to Generate Barcodes Pin
Peace ON11-May-10 21:50
Peace ON11-May-10 21:50 
GeneralRe: Free/Open Source Library to Generate Barcodes Pin
Rafferty Uy11-May-10 22:44
Rafferty Uy11-May-10 22:44 
AnswerRe: Free/Open Source Library to Generate Barcodes Pin
Luc Pattyn12-May-10 1:58
sitebuilderLuc Pattyn12-May-10 1:58 
Questionproblem while using delegates in c# Pin
sindhumahe11-May-10 19:42
sindhumahe11-May-10 19:42 
hi all,

i am trying to export my C++ functions to C#. and i have succeeded in exporting them. while importing the functions. now to one of such functions, i want to pass two newly defined functions in C# as arguments, how should i achieve this. kindly help me.i am very badly in need of the solution to complete my project.

this is how i have implemented:

1. function exporting from C++:

extern __declspec(dllexport) bool Callregistercallback(CRTSPWrapper* pObject,funccallback fptr_video,funccallback fptr_audio,void* ptr);

where funccallback is a function pointer

2. function call in C++ test application

m_oSarixrtsp->registercallback(GetVideoPacket,GetAudioPacket,NULL);
where GetVideoPacket and GetAudioPackets are functions that are defined in the main of C++

3.function importing in C#

[DllImport("sampleclient_dll.dll", CharSet = CharSet.Ansi)]
static private extern bool Callregistercallback(IntPtr pTestClassObject,IntPtr fptr_video,IntPtr fptr_audio,IntPtr ptr);

4.function defintion in C#:

here i have defined two delegates to the functions namely Getvideopacket and getaudiopacket as follows:

public delegate void getadelegate(char[] pBuffer, int nSize);
public delegate void getvdelegate(char[] pBuffer, int nSize);

public bool registercallback([MarshalAs(UnmanagedType.FunctionPtr)]IntPtr fptr_video, [MarshalAs(UnmanagedType.FunctionPtr)] IntPtr fptr_audio, IntPtr ptr)
{
getvdelegate objv = new getvdelegate(Getvideopacket);
getadelegate obja = new getadelegate(Getaudiopacket);

return Callregistercallback(this.m_pNativeObject, fptr_video, fptr_audio, ptr);
}

5.function call from test application in C#:

testclass.registercallback(Getvideopacket,Getaudiopacket,null);


this is resulting in a compile time error stating: cannot convert a System method to System IntPtr.

Kinldy help me out please. thanks in advance.


regards

sindhu
AnswerRe: problem while using delegates in c# Pin
DaveyM6911-May-10 21:33
professionalDaveyM6911-May-10 21:33 
AnswerRe: problem while using delegates in c# Pin
Luc Pattyn12-May-10 2:00
sitebuilderLuc Pattyn12-May-10 2:00 
AnswerRe: problem while using delegates in c# Pin
Hristo-Bojilov12-May-10 3:10
Hristo-Bojilov12-May-10 3:10 
Questionhow to create cab file from setup exe file using cabsdk Pin
NarVish11-May-10 19:37
NarVish11-May-10 19:37 
AnswerRe: how to create cab file from setup exe file using cabsdk Pin
Abhinav S11-May-10 20:20
Abhinav S11-May-10 20:20 
QuestionHow to encrypt data in mySQL using C# Pin
MissNano11-May-10 18:34
MissNano11-May-10 18:34 
AnswerRe: How to encrypt data in mySQL using C# Pin
Peace ON11-May-10 22:14
Peace ON11-May-10 22:14 
QuestionDate Pickers with Checkboxes and Modified Rows Pin
gmhanna11-May-10 17:44
gmhanna11-May-10 17:44 
AnswerRe: Date Pickers with Checkboxes and Modified Rows Pin
Stanciu Vlad11-May-10 19:27
Stanciu Vlad11-May-10 19:27 
QuestionWhere to get started Pin
crosson11-May-10 17:09
crosson11-May-10 17:09 
AnswerRe: Where to get started Pin
Peace ON11-May-10 21:58
Peace ON11-May-10 21:58 
AnswerRe: Where to get started Pin
Richard MacCutchan11-May-10 22:27
mveRichard MacCutchan11-May-10 22:27 
AnswerRe: Where to get started Pin
crosson12-May-10 10:51
crosson12-May-10 10:51 
AnswerRe: Where to get started Pin
Ravi Sant14-Apr-11 1:22
Ravi Sant14-Apr-11 1:22 
QuestionSerialization Question Pin
Kevin Marois11-May-10 11:14
professionalKevin Marois11-May-10 11:14 
AnswerRe: Serialization Question Pin
William Winner11-May-10 11:40
William Winner11-May-10 11:40 
GeneralRe: Serialization Question Pin
Kevin Marois11-May-10 11:55
professionalKevin Marois11-May-10 11:55 

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.