473,626 Members | 3,183 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MC++ Question

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
Dec 9 '05 #1
1 1255
> 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
Dec 9 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1260
by: Daniel Lidström | last post by:
Hi, how would I do the following (in CSharp) with MC++? C#: namespace LX { public struct Declarations { public const string SchemaVersion = "1.0";
1
1392
by: Vladimir Scherbina Nickolaevich | last post by:
hello all, I need to hook some event handler in Managed C++code into event, that is declared, and is fired in C# code. as i understand, this maybe achieved via __hook, but when i write code like this __hook(&SomeControl::SomeEvent:, controlInstance, &CSomeClass::EventHandler);
3
1531
by: Philip | last post by:
I am invoking a mc++ method from C# via an unsafe code block. The reason for the unsafe code block is that I am receiving a int as a return parameter. I am invoking the method with a "ref iValue" int parameter.... and in the mc++ code I define "int* iValue" for the same int parameter. As a result I have to place the invoking code in an unsafe code block. Is there not a means to update a int parameter between C# and mc++ without...
4
1684
by: Daniel Lidström | last post by:
Hello, is it possible to ``use CS to code a class, and (M)C++ for the logic''? Sorry if this sounds vague, I'm not really sure myself what it means. Does anyone have any ideas? -- Daniel
0
1142
by: Sam Carleton | last post by:
I am looking for advice on best practices. I am coding against a digital camera SDK. One of the callback functions returns the large, multi megabyte images in smaller chunks. Some of the images will be JPG, others will be RAW. GUI is C# Middle layer: MC++ Digital Camera SDK: UMC SDK The MC++ layer will gather all the different pieces of the images
2
2509
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a pointer or reference to a derived type of the base class's return type. In .NET the overridden virtual function is similar, but an actual parameter of the function can be a derived reference from the base class's reference also. This dichotomy...
2
1906
by: Lev | last post by:
Hi, I have some code that does reflection on an assembly I load. When I try to get the attributes on one of the methods implemented in the assembly, the MC++ version does not return anything. See code below: Object __gc* memberAttributes = info->GetCustomAttributes(__typeof(EntryPointAttribute), false);
7
1627
by: Tommy Vercetti | last post by:
The first three of these statements work. The fourth doesn't. String::Format("{0}{0}{0}{0}", S""); String::Format("{0}{1}{0}{0}", S"", S""); String::Format("{0}{1}{2}{0}", S"", S"", S""); String::Format("{0}{1}{2}{3}", S"", S"", S"", S""); Question #1: Why? Question #2: What is the simplest way to get this to work. I would
0
1602
by: Maxwell | last post by:
Hello, I recently completed a MC++ (VS2003) DLL that wraps a non MFC C++ DLL and need to use it in a MC++ Console Application (no forms/guis of any kind just output to console). Trouble is that when I ran it and looked at memory usage (in Windows task manager) it looked as if there was a very slow leak. To isolate the issue:
8
2197
by: WebSnozz | last post by:
I have an application written in C that does a lot of low level stuff. It does a lot of things like casting from void*'s. I want to create a new GUI for it in either C# or MC++, but reuse the existing code. The options I've considered so far: 1. Create a new MC++ GUI project and add the *.c files to them and mark them with pragma unamanged. However, the /clr option does not compile *.c files, so I rename them to *.cpp, and now they...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.