PC Review


Reply
Thread Tools Rate Thread

Developing for the Compact framework

 
 
Denis C
Guest
Posts: n/a
 
      26th Nov 2003
Hi,

I have a C library and a VB .NET app using the C library
that I want to use on Windows CE 4.2. I have installed
EVC++ 4.0 and VS .NET 2003. Unfortunately they both
deploy to different emulators. Is it possible to set the
target emulator? Or could I install some other compact
framework environment and compile both programs for that
environment?

Denis C

Here also is the question unanswered from my previous
post concerning C structs containing arrays:

Sorry I forgot to put my name on the last one. I'm
wondering if I'm on the right track for dealing with char
arrays from C in VB.

Here's what I'm going to try:

typedef struct GetLongRTS *GetLongRT;
struct GetLongRTS{
char sval[30];
LONG lval;
};

Public Structure GetLongRTS
Public sval As StringPtr
Public lval As Integer
End Structure

Public Structure StringPtr
Private szString As IntPtr

Public Sub New(ByVal s As Integer)
Me.szString = Memory.AllocHLocal(2 * (1 + s))
End Sub

Public Overrides Function ToString() As String
Return Marshal.PtrToStringUni(Me.szString)
End Function

Public Sub Free()
Memory.FreeHLocal(Me.szString)
End Sub
End Structure

Dim ptr As IntPtr = DBAccessFuncDecl.GetLongVal()
Dim obj As DBAccessFuncDecl.GetLongRTS
obj.sval = New DBAccessFuncDecl.StringPtr(30)
obj = CType(Marshal.PtrToStructure(ptr, GetType
(DBAccessFuncDecl.GetLongRTS)),
DBAccessFuncDecl.GetLongRTS)


Is that the idea??

And then we also have some 2d arrays, char[20][20].
Can this approach work?

Thanks

Denis

..


 
Reply With Quote
 
 
 
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      26th Nov 2003
Don't use the emulator. Use the target device. You'll spend a lot of time
screwing around, only to find that you have to test on the real device,
anyway.

I think that your mapping of structure from C to VB.NET is incorrect. I
think that Chris suggested this previously, but you should look at the
OpenNetCF library source for some tips on doing this type of thing.
Specifically, as I recall, the time zone stuff does this sort of thing. It
creates a class which represents the C data type. Rather than storing the
fields, though, it stores an array of bytes to represent the C structure
memory layout. When you access the 'fields' from outside an instance of the
class, the class converts the value you are sending in to an array of bytes
and copies the bytes to the right offset in the byte array. The reverse is
done when you read a 'field' of the structure externally. When you need to
call a C API and pass the structure, you do something like this:

CFunction( csobject.ToByteArray() );

where the ToByteArray() method simply returns the structure's internal byte
array. The CFunction can even alter the structure contents and you'll be
able to see them in the managed code after the call.

For your case, you may want to build some accessors for array elements, but
the basic scheme should work just fine.

Paul T.

"Denis C" <(E-Mail Removed)> wrote in message
news:0c1d01c3b44f$da8f5b30$(E-Mail Removed)...
> Hi,
>
> I have a C library and a VB .NET app using the C library
> that I want to use on Windows CE 4.2. I have installed
> EVC++ 4.0 and VS .NET 2003. Unfortunately they both
> deploy to different emulators. Is it possible to set the
> target emulator? Or could I install some other compact
> framework environment and compile both programs for that
> environment?
>
> Denis C
>
> Here also is the question unanswered from my previous
> post concerning C structs containing arrays:
>
> Sorry I forgot to put my name on the last one. I'm
> wondering if I'm on the right track for dealing with char
> arrays from C in VB.
>
> Here's what I'm going to try:
>
> typedef struct GetLongRTS *GetLongRT;
> struct GetLongRTS{
> char sval[30];
> LONG lval;
> };
>
> Public Structure GetLongRTS
> Public sval As StringPtr
> Public lval As Integer
> End Structure
>
> Public Structure StringPtr
> Private szString As IntPtr
>
> Public Sub New(ByVal s As Integer)
> Me.szString = Memory.AllocHLocal(2 * (1 + s))
> End Sub
>
> Public Overrides Function ToString() As String
> Return Marshal.PtrToStringUni(Me.szString)
> End Function
>
> Public Sub Free()
> Memory.FreeHLocal(Me.szString)
> End Sub
> End Structure
>
> Dim ptr As IntPtr = DBAccessFuncDecl.GetLongVal()
> Dim obj As DBAccessFuncDecl.GetLongRTS
> obj.sval = New DBAccessFuncDecl.StringPtr(30)
> obj = CType(Marshal.PtrToStructure(ptr, GetType
> (DBAccessFuncDecl.GetLongRTS)),
> DBAccessFuncDecl.GetLongRTS)
>
>
> Is that the idea??
>
> And then we also have some 2d arrays, char[20][20].
> Can this approach work?
>
> Thanks
>
> Denis
>
> .
>
>



 
Reply With Quote
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      26th Nov 2003
I go one step further and create an explicit or implicit operator to get the
byte array, as I personally don't like calling a ToByteArray() method, but
that's a style thing. The WinAPI has a lot of these classes. Look at any
one of these classes: WAVEHDR, WAVEINCAPS, SYSTEMTIME, TZREG,
TIME_ZONE_INFORMATION, FileInformation, BITMAPINFOHEADER, BITMAPFILEHEADER


--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


"Paul G. Tobey [eMVP]" <ptobey_no_spam@instrument_no_spam.com> wrote in
message news:O$(E-Mail Removed)...
> Don't use the emulator. Use the target device. You'll spend a lot of

time
> screwing around, only to find that you have to test on the real device,
> anyway.
>
> I think that your mapping of structure from C to VB.NET is incorrect. I
> think that Chris suggested this previously, but you should look at the
> OpenNetCF library source for some tips on doing this type of thing.
> Specifically, as I recall, the time zone stuff does this sort of thing.

It
> creates a class which represents the C data type. Rather than storing the
> fields, though, it stores an array of bytes to represent the C structure
> memory layout. When you access the 'fields' from outside an instance of

the
> class, the class converts the value you are sending in to an array of

bytes
> and copies the bytes to the right offset in the byte array. The reverse

is
> done when you read a 'field' of the structure externally. When you need

to
> call a C API and pass the structure, you do something like this:
>
> CFunction( csobject.ToByteArray() );
>
> where the ToByteArray() method simply returns the structure's internal

byte
> array. The CFunction can even alter the structure contents and you'll be
> able to see them in the managed code after the call.
>
> For your case, you may want to build some accessors for array elements,

but
> the basic scheme should work just fine.
>
> Paul T.
>
> "Denis C" <(E-Mail Removed)> wrote in message
> news:0c1d01c3b44f$da8f5b30$(E-Mail Removed)...
> > Hi,
> >
> > I have a C library and a VB .NET app using the C library
> > that I want to use on Windows CE 4.2. I have installed
> > EVC++ 4.0 and VS .NET 2003. Unfortunately they both
> > deploy to different emulators. Is it possible to set the
> > target emulator? Or could I install some other compact
> > framework environment and compile both programs for that
> > environment?
> >
> > Denis C
> >
> > Here also is the question unanswered from my previous
> > post concerning C structs containing arrays:
> >
> > Sorry I forgot to put my name on the last one. I'm
> > wondering if I'm on the right track for dealing with char
> > arrays from C in VB.
> >
> > Here's what I'm going to try:
> >
> > typedef struct GetLongRTS *GetLongRT;
> > struct GetLongRTS{
> > char sval[30];
> > LONG lval;
> > };
> >
> > Public Structure GetLongRTS
> > Public sval As StringPtr
> > Public lval As Integer
> > End Structure
> >
> > Public Structure StringPtr
> > Private szString As IntPtr
> >
> > Public Sub New(ByVal s As Integer)
> > Me.szString = Memory.AllocHLocal(2 * (1 + s))
> > End Sub
> >
> > Public Overrides Function ToString() As String
> > Return Marshal.PtrToStringUni(Me.szString)
> > End Function
> >
> > Public Sub Free()
> > Memory.FreeHLocal(Me.szString)
> > End Sub
> > End Structure
> >
> > Dim ptr As IntPtr = DBAccessFuncDecl.GetLongVal()
> > Dim obj As DBAccessFuncDecl.GetLongRTS
> > obj.sval = New DBAccessFuncDecl.StringPtr(30)
> > obj = CType(Marshal.PtrToStructure(ptr, GetType
> > (DBAccessFuncDecl.GetLongRTS)),
> > DBAccessFuncDecl.GetLongRTS)
> >
> >
> > Is that the idea??
> >
> > And then we also have some 2d arrays, char[20][20].
> > Can this approach work?
> >
> > Thanks
> >
> > Denis
> >
> > .
> >
> >

>
>



 
Reply With Quote
 
Denis C
Guest
Posts: n/a
 
      26th Nov 2003

Okay. So if I can get the device from the company, if I
connect it evc and vs .net 2003 will compile for the
correct target? With the emulators I'm still getting a
MethodNotFound type exception and I am assuming this is
because the library isn't compiled correctly.

So, just to be sure I'm understanding you correctly, I'm
looking at creating a class for each C type I need to
handle? i.e. char id[30] would have its own class.

Or do you mean a class for each struct that contains
array types?

The structs without array types inside are posing no
problems. We hava declared "equivilent structures in VB
and can access the data inside them without problems.
This leads me to believe you are suggesting the first
option. If so, I thought that was what I was doing in
the attached example. Instead of a class I created a
struct called StringPtr that was allocated the space
necessary to hold the 30 charater array it would be
exected to hold when the C struct was assigned to it.

Am I making any sense?

Denis
>-----Original Message-----
>Don't use the emulator. Use the target device. You'll

spend a lot of time
>screwing around, only to find that you have to test on

the real device,
>anyway.
>
>I think that your mapping of structure from C to VB.NET

is incorrect. I
>think that Chris suggested this previously, but you

should look at the
>OpenNetCF library source for some tips on doing this

type of thing.
>Specifically, as I recall, the time zone stuff does this

sort of thing. It
>creates a class which represents the C data type.

Rather than storing the
>fields, though, it stores an array of bytes to represent

the C structure
>memory layout. When you access the 'fields' from

outside an instance of the
>class, the class converts the value you are sending in

to an array of bytes
>and copies the bytes to the right offset in the byte

array. The reverse is
>done when you read a 'field' of the structure

externally. When you need to
>call a C API and pass the structure, you do something

like this:
>
>CFunction( csobject.ToByteArray() );
>
>where the ToByteArray() method simply returns the

structure's internal byte
>array. The CFunction can even alter the structure

contents and you'll be
>able to see them in the managed code after the call.
>
>For your case, you may want to build some accessors for

array elements, but
>the basic scheme should work just fine.
>
>Paul T.
>
>"Denis C" <(E-Mail Removed)> wrote in

message
>news:0c1d01c3b44f$da8f5b30$(E-Mail Removed)...
>> Hi,
>>
>> I have a C library and a VB .NET app using the C

library
>> that I want to use on Windows CE 4.2. I have installed
>> EVC++ 4.0 and VS .NET 2003. Unfortunately they both
>> deploy to different emulators. Is it possible to set

the
>> target emulator? Or could I install some other compact
>> framework environment and compile both programs for

that
>> environment?
>>
>> Denis C
>>
>> Here also is the question unanswered from my previous
>> post concerning C structs containing arrays:
>>
>> Sorry I forgot to put my name on the last one. I'm
>> wondering if I'm on the right track for dealing with

char
>> arrays from C in VB.
>>
>> Here's what I'm going to try:
>>
>> typedef struct GetLongRTS *GetLongRT;
>> struct GetLongRTS{
>> char sval[30];
>> LONG lval;
>> };
>>
>> Public Structure GetLongRTS
>> Public sval As StringPtr
>> Public lval As Integer
>> End Structure
>>
>> Public Structure StringPtr
>> Private szString As IntPtr
>>
>> Public Sub New(ByVal s As Integer)
>> Me.szString = Memory.AllocHLocal(2 * (1 +

s))
>> End Sub
>>
>> Public Overrides Function ToString() As String
>> Return Marshal.PtrToStringUni(Me.szString)
>> End Function
>>
>> Public Sub Free()
>> Memory.FreeHLocal(Me.szString)
>> End Sub
>> End Structure
>>
>> Dim ptr As IntPtr = DBAccessFuncDecl.GetLongVal

()
>> Dim obj As DBAccessFuncDecl.GetLongRTS
>> obj.sval = New DBAccessFuncDecl.StringPtr(30)
>> obj = CType(Marshal.PtrToStructure(ptr, GetType
>> (DBAccessFuncDecl.GetLongRTS)),
>> DBAccessFuncDecl.GetLongRTS)
>>
>>
>> Is that the idea??
>>
>> And then we also have some 2d arrays, char[20][20].
>> Can this approach work?
>>
>> Thanks
>>
>> Denis
>>
>> .
>>
>>

>
>
>.
>

 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      26th Nov 2003
VS.NET, if you've configured it to generate a Smart Device Application,
doesn't compile for a particular device type, to speak of. You can choose
Pocket PC or Windows CE.NET from the toolbar.

When you compile the DLL, you need to make sure that your target selection
is the device, and not an emulator of the device, and that you're compiling
for the proper processor type.

Other than that, it pretty much just works. If you're getting lots of
Missing Method exceptions, verify that you are properly exporting the
functions you are trying to call. The dependency viewer, depends.exe, will
tell you this when you run it on your DLL. Check the exported function
names and make sure that they don't have a bunch of decorations on them, as
they will if the DLL is written in C++ and the functions are not marked
'extern "C"'.

Yes, I'd say that, for structured types, you'll need a managed class for
each one. For char id[30], that's just an array of Byte, so you don't need
a special type for that, if you're passing the array directly (*that* can be
marshaled). However, if you have an array embedded in a structure, you'll
need to do something similar to the classes that Chris mentions.

OK, the missing code for StringPtr misled me.

Paul T.


"Denis C" <(E-Mail Removed)> wrote in message
news:02e701c3b45a$9ab0f310$(E-Mail Removed)...
>
> Okay. So if I can get the device from the company, if I
> connect it evc and vs .net 2003 will compile for the
> correct target? With the emulators I'm still getting a
> MethodNotFound type exception and I am assuming this is
> because the library isn't compiled correctly.
>
> So, just to be sure I'm understanding you correctly, I'm
> looking at creating a class for each C type I need to
> handle? i.e. char id[30] would have its own class.
>
> Or do you mean a class for each struct that contains
> array types?
>
> The structs without array types inside are posing no
> problems. We hava declared "equivilent structures in VB
> and can access the data inside them without problems.
> This leads me to believe you are suggesting the first
> option. If so, I thought that was what I was doing in
> the attached example. Instead of a class I created a
> struct called StringPtr that was allocated the space
> necessary to hold the 30 charater array it would be
> exected to hold when the C struct was assigned to it.
>
> Am I making any sense?
>
> Denis
> >-----Original Message-----
> >Don't use the emulator. Use the target device. You'll

> spend a lot of time
> >screwing around, only to find that you have to test on

> the real device,
> >anyway.
> >
> >I think that your mapping of structure from C to VB.NET

> is incorrect. I
> >think that Chris suggested this previously, but you

> should look at the
> >OpenNetCF library source for some tips on doing this

> type of thing.
> >Specifically, as I recall, the time zone stuff does this

> sort of thing. It
> >creates a class which represents the C data type.

> Rather than storing the
> >fields, though, it stores an array of bytes to represent

> the C structure
> >memory layout. When you access the 'fields' from

> outside an instance of the
> >class, the class converts the value you are sending in

> to an array of bytes
> >and copies the bytes to the right offset in the byte

> array. The reverse is
> >done when you read a 'field' of the structure

> externally. When you need to
> >call a C API and pass the structure, you do something

> like this:
> >
> >CFunction( csobject.ToByteArray() );
> >
> >where the ToByteArray() method simply returns the

> structure's internal byte
> >array. The CFunction can even alter the structure

> contents and you'll be
> >able to see them in the managed code after the call.
> >
> >For your case, you may want to build some accessors for

> array elements, but
> >the basic scheme should work just fine.
> >
> >Paul T.
> >
> >"Denis C" <(E-Mail Removed)> wrote in

> message
> >news:0c1d01c3b44f$da8f5b30$(E-Mail Removed)...
> >> Hi,
> >>
> >> I have a C library and a VB .NET app using the C

> library
> >> that I want to use on Windows CE 4.2. I have installed
> >> EVC++ 4.0 and VS .NET 2003. Unfortunately they both
> >> deploy to different emulators. Is it possible to set

> the
> >> target emulator? Or could I install some other compact
> >> framework environment and compile both programs for

> that
> >> environment?
> >>
> >> Denis C
> >>
> >> Here also is the question unanswered from my previous
> >> post concerning C structs containing arrays:
> >>
> >> Sorry I forgot to put my name on the last one. I'm
> >> wondering if I'm on the right track for dealing with

> char
> >> arrays from C in VB.
> >>
> >> Here's what I'm going to try:
> >>
> >> typedef struct GetLongRTS *GetLongRT;
> >> struct GetLongRTS{
> >> char sval[30];
> >> LONG lval;
> >> };
> >>
> >> Public Structure GetLongRTS
> >> Public sval As StringPtr
> >> Public lval As Integer
> >> End Structure
> >>
> >> Public Structure StringPtr
> >> Private szString As IntPtr
> >>
> >> Public Sub New(ByVal s As Integer)
> >> Me.szString = Memory.AllocHLocal(2 * (1 +

> s))
> >> End Sub
> >>
> >> Public Overrides Function ToString() As String
> >> Return Marshal.PtrToStringUni(Me.szString)
> >> End Function
> >>
> >> Public Sub Free()
> >> Memory.FreeHLocal(Me.szString)
> >> End Sub
> >> End Structure
> >>
> >> Dim ptr As IntPtr = DBAccessFuncDecl.GetLongVal

> ()
> >> Dim obj As DBAccessFuncDecl.GetLongRTS
> >> obj.sval = New DBAccessFuncDecl.StringPtr(30)
> >> obj = CType(Marshal.PtrToStructure(ptr, GetType
> >> (DBAccessFuncDecl.GetLongRTS)),
> >> DBAccessFuncDecl.GetLongRTS)
> >>
> >>
> >> Is that the idea??
> >>
> >> And then we also have some 2d arrays, char[20][20].
> >> Can this approach work?
> >>
> >> Thanks
> >>
> >> Denis
> >>
> >> .
> >>
> >>

> >
> >
> >.
> >



 
Reply With Quote
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      26th Nov 2003
Let's say you have this:

typedef struct GetLongRTS *GetLongRT;
struct GetLongRTS{
char sval[30];
LONG lval;
};

It would look something like this in C#:

class GetLongRTS
{
byte[] bytes = new byte[34];
public char[] sval
{
get
{
char[] b = new char[34];
Buffer.BlockCopy( b, 0, bytes, 0, 34);
return b;
}
}

public long lval
{
get { return BitConverter.ToUInt32(data, 34); }
}

public static implicit operator byte[]( WAVEHDR wh )
{
return bytes;
}
}



--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


 
Reply With Quote
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      26th Nov 2003
obviously I made a mistake...

public static implicit operator byte[]( GetLongRTS rts )
{
return rts.bytes;
}

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


"Chris Tacke, eMVP" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Let's say you have this:
>
> typedef struct GetLongRTS *GetLongRT;
> struct GetLongRTS{
> char sval[30];
> LONG lval;
> };
>
> It would look something like this in C#:
>
> class GetLongRTS
> {
> byte[] bytes = new byte[34];
> public char[] sval
> {
> get
> {
> char[] b = new char[34];
> Buffer.BlockCopy( b, 0, bytes, 0, 34);
> return b;
> }
> }
>
> public long lval
> {
> get { return BitConverter.ToUInt32(data, 34); }
> }
>
> public static implicit operator byte[]( WAVEHDR wh )
> {
> return bytes;
> }
> }
>
>
>
> --
> Chris Tacke, eMVP
> Co-Founder and Advisory Board Member
> www.OpenNETCF.org
> ---
> Windows CE Product Manager
> Applied Data Systems
> www.applieddata.net
>
>



 
Reply With Quote
 
Denis C
Guest
Posts: n/a
 
      26th Nov 2003
Okay, the compiling sounds like I thought. For some
reason it's not working but that's another story

What I was getting at with the char id[30] was if it is
in a C struct can my VB Structure contain a managed class
with the Byte array as you were suggesting as well as any
other types I need, like the StringPtr example?

so lets say C struct like before:

typedef struct GetLongRTS *GetLongRT;
struct GetLongRTS{
char sval[30];
LONG lval;
};

VB Structure as before:

Public Structure GetLongRTS
Public sval As **CharArrayClass**
Public lval As Integer
End Structure

Where CharArrayClass contains a byte array for holding
the data.

then:

Dim ptr As IntPtr = DBAccessFuncDecl.GetLongVal()
Dim obj As DBAccessFuncDecl.GetLongRTS

obj = CType(Marshal.PtrToStructure(ptr, GetType
(DBAccessFuncDecl.GetLongRTS)),DBAccessFuncDecl.GetLongRTS
)


Or rather a class GetLongRTS which contains a byte array
internally and methods like getSval() return the expected
String and getLval() returns the expected long?

then:

the same as above.

Am I understanding what you're saying or am I way off?

Denis

 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      26th Nov 2003
You can't just pass a pointer to a managed structure if the structure
contains an array, no. That's not able to be marshaled by the system and
might, for all I know, cause a missing method exception itself.

Paul T.

"Denis C" <(E-Mail Removed)> wrote in message
news:7ae901c3b46c$1121eed0$(E-Mail Removed)...
> Okay, the compiling sounds like I thought. For some
> reason it's not working but that's another story
>
> What I was getting at with the char id[30] was if it is
> in a C struct can my VB Structure contain a managed class
> with the Byte array as you were suggesting as well as any
> other types I need, like the StringPtr example?
>
> so lets say C struct like before:
>
> typedef struct GetLongRTS *GetLongRT;
> struct GetLongRTS{
> char sval[30];
> LONG lval;
> };
>
> VB Structure as before:
>
> Public Structure GetLongRTS
> Public sval As **CharArrayClass**
> Public lval As Integer
> End Structure
>
> Where CharArrayClass contains a byte array for holding
> the data.
>
> then:
>
> Dim ptr As IntPtr = DBAccessFuncDecl.GetLongVal()
> Dim obj As DBAccessFuncDecl.GetLongRTS
>
> obj = CType(Marshal.PtrToStructure(ptr, GetType
> (DBAccessFuncDecl.GetLongRTS)),DBAccessFuncDecl.GetLongRTS
> )
>
>
> Or rather a class GetLongRTS which contains a byte array
> internally and methods like getSval() return the expected
> String and getLval() returns the expected long?
>
> then:
>
> the same as above.
>
> Am I understanding what you're saying or am I way off?
>
> Denis
>



 
Reply With Quote
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      26th Nov 2003
You should accept the struct from C as a byte array, then add an
operator/ctor pair to go from a byte[] to a class:

public GetLongRTS(byte[] data)
{
Buffer.BlockCopy(data, 0, bytes, 0, data.Length);
}

public static implicit operator GetLongRTS(byte[] data)
{
return new GetLongRTS(data);
}

This makes a byte array and your struct pretty transportable from one to the
other and back. Keep in mind I used implicit operators. For clarity
explicit may be better so you have to do a cast. Depends on how many
different classes like this you have in your project. If it's 1 or 2,
implicit is fine.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


"Denis C" <(E-Mail Removed)> wrote in message
news:053301c3b470$a37f6d80$(E-Mail Removed)...
> Thanks for your patience guys. I'm just finishing up my
> CompSci degree and all the .NET stuff is new to me, let
> alone the Compact Framework.
>
> Anyways, the code is very helpfull. When I am receiving
> the pointer to the C struct can I still receive it as an
> IntPtr and then Marshall it to the appropriate class?
>
> Denis
>
> >-----Original Message-----
> >Let's say you have this:
> >
> >typedef struct GetLongRTS *GetLongRT;
> >struct GetLongRTS{
> > char sval[30];
> > LONG lval;
> >};
> >
> >It would look something like this in C#:
> >
> >class GetLongRTS
> >{
> > byte[] bytes = new byte[34];
> > public char[] sval
> > {
> > get
> > {
> > char[] b = new char[34];
> > Buffer.BlockCopy( b, 0, bytes, 0, 34);
> > return b;
> > }
> > }
> >
> > public long lval
> > {
> > get { return BitConverter.ToUInt32(data, 34); }
> > }
> >
> > public static implicit operator byte[]( WAVEHDR wh )
> > {
> > return bytes;
> > }
> >}
> >
> >
> >
> >--
> >Chris Tacke, eMVP
> >Co-Founder and Advisory Board Member
> >www.OpenNETCF.org
> >---
> >Windows CE Product Manager
> >Applied Data Systems
> >www.applieddata.net
> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Developing Applications for both Compact and Full Framework Ryan DeVore Microsoft Dot NET Compact Framework 1 15th Oct 2005 09:47 AM
RE: What is the best language overall for developing for compact framework? =?Utf-8?B?RGFuaWVsIFBldGVyc3Nvbg==?= Microsoft Dot NET Compact Framework 4 19th Mar 2004 01:09 PM
Re: What is the best language overall for developing for compact framework? Dick Grier Microsoft Dot NET Compact Framework 0 15th Mar 2004 10:18 PM
Re: What is the best language overall for developing for compact framework? Chris Tacke, eMVP Microsoft Dot NET Compact Framework 0 15th Mar 2004 06:31 PM
Compact framework - Developing an MDI application. =?Utf-8?B?cGF1bA==?= Microsoft Dot NET 3 10th Mar 2004 04:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:06 AM.