C# Prototype & Delegate in Compact Framework

G

Guest

I have a PocketPC .Net application (Compact Framework) that calls a Win32
DLL. This DLL in turn has a WINAPI type callback. Following is the actual
prototype.

Win32 DLL Function Prototype
-----------
Status = XferFiles(int PortID, int Direction, int Protocol, LPCTSTR Fspec,
int Flag, int (WINAPI *Callback)(int Chgflg, char *Fname, long Bytcnt, int
Curblk, int Errcnt, unsigned Rate));

1. What would the above C# function prototype look like?
2. And the delegate for the callback function?

Thanks
 
V

Vadym Stetsyak

Hello, ThinkRS232!

T> Win32 DLL Function Prototype
T> -----------
T> Status = XferFiles(int PortID, int Direction, int Protocol, LPCTSTR
T> Fspec, int Flag, int (WINAPI *Callback)(int Chgflg, char *Fname, long
T> Bytcnt, int Curblk, int Errcnt, unsigned Rate));

T> 1. What would the above C# function prototype look like?
T> 2. And the delegate for the callback function?

What type returns XferFiels(...)?

C#
[DllImport("your.dll", SetLastError=true)]
XferFiles( int portID, int Direction, int Protocol, string Fspec, int Flag, CallbackDelegate callback);

delegate int CallbackDelegate(int Chgflg,
[MarshalAs(UnmanagedType.LPStr]
string Fname,
long Bytcnt,
int Curblk,
int Errcnt,
uint Rate);

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
G

Guest

Thanks for the reply. I am getting the error

"B:\CdrvCENet\CdrvCENet\CdrvCE.cs(778): The type or namespace name
'MarshalAs' could not be found (are you missing a using directive or an
assembly reference?)"

Is MarshalAs supported in the 1.x .Net Compact Framework? Otherwise, what
could be the error?

Regards
 
V

Vadym Stetsyak

Hello, ThinkRS232!

T> "B:\CdrvCENet\CdrvCENet\CdrvCE.cs(778): The type or namespace name
T> 'MarshalAs' could not be found (are you missing a using directive or an
T> assembly reference?)"

T> Is MarshalAs supported in the 1.x .Net Compact Framework? Otherwise,
T> what could be the error?

MarshalAs is supported only in CF 2.0.
For more info what is supported in CF 1.0 have a look at
( http://www.c-sharpcorner.com/Code/2004/June/DevelopCFApps.asp )

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top