MC++ Question

S

Shawn B.

Greetings,

With a Managed class, if I'm #including a Windows SDK header file, and call
an API, it appears (according to .NET Reflector) that it automatically
generates a [DLLImport()] for each API call that I make. In other words, it
isn't actually calling the native method directly, right?

So, when I create a variable based on a struct (such as POINT or COORD) in
my Managed class, I can't just pass it in to the API call, right? It seems
that the compiler generates an empty stub of each struct I use from the SDK
header files, but it doesn't actually generate the members of the struct.
Is this left as an excercise for me to do?

One of the more interesting problems I can't seem to solve, if I have a
WinAPI struct defined as static at the class-level on a Managed class, and
use it in a function, it won't let me because of casting a __gc* pointer or
something like that. But if I define the same verianle locally, it works
just fine. I can't seem to figure out why. Perhaps I need to do something
to the class-member variable? (correct my terminology, its been many years
since I programmed C++ and I've about forgotten everything from lack of
practice).

One of the reasons I moved this project into MC++ is because I tired of
redfining API after API and struct after struct in C#. I thought that it
would be easier in MC++. And for the most part, it is a breeze when I
actually figure things out. But, I really don't want to keep redefining the
structs unless I have to. If I must, I must, its still easier (and more
interesting) than doing it in C#. Is there an easy way or is this it? Does
it get any easier with the 2005 implementation of IJW?


Thanks,
Shawn
 
S

Shawn B.

With a Managed class, if I'm #including a Windows SDK header file, and
call an API, it appears (according to .NET Reflector) that it
automatically generates a [DLLImport()] for each API call that I make. In
other words, it isn't actually calling the native method directly, right?

So, when I create a variable based on a struct (such as POINT or COORD) in
my Managed class, I can't just pass it in to the API call, right? It
seems that the compiler generates an empty stub of each struct I use from
the SDK header files, but it doesn't actually generate the members of the
struct. Is this left as an excercise for me to do?

One of the more interesting problems I can't seem to solve, if I have a
WinAPI struct defined as static at the class-level on a Managed class, and
use it in a function, it won't let me because of casting a __gc* pointer
or something like that. But if I define the same verianle locally, it
works just fine. I can't seem to figure out why. Perhaps I need to do
something to the class-member variable? (correct my terminology, its been
many years since I programmed C++ and I've about forgotten everything from
lack of practice).

One of the reasons I moved this project into MC++ is because I tired of
redfining API after API and struct after struct in C#. I thought that it
would be easier in MC++. And for the most part, it is a breeze when I
actually figure things out. But, I really don't want to keep redefining
the structs unless I have to. If I must, I must, its still easier (and
more interesting) than doing it in C#. Is there an easy way or is this
it? Does it get any easier with the 2005 implementation of IJW?

It seems the best way for me to achieve this, is to create the API wrapper
in unmanaged code and then create a managed wrapper around the unmanaged
class, this seems to give me the results I'm looking for.


Thanks,
Shawn
 

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