Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an API ( containing DLLs , libs, and Headers) ( in C++ /MFC)

I cannot access the source code.

I am trying to wrap those header files with C++/CLI to use them later in C#.


It tells me DWORD / BYTE /BOOL … not defined

It also shows me this error : IntelliSense : directive #error : WINDOWS.H already included. MFC apps must not #include windows.h

Although when I look for #include windows.h in the solution it shows no result

( I did not change anything in the header files , and when i use them in C++ they work just fine)

What I have tried:

I am using MFC in a shared DLL in my C++/CLI project .

I tryed using PInvoke directly in c# but it seems that i cannot marshal the whole class ( i cannot use the constructor)
Posted
Updated 24-Mar-16 0:13am

1 solution

The windows.h error is typical and correct (in bigger abstract sense), so you shouldnt or cant use this header. You need to include the needed headers in an other manner, or define some values yourself.

My advice: Make a wrapper dll without ANY external MFC class in its interfaces and link statically. Use native interfaces as char* or int for data exchange. A bit annoying, but it works.

I wrote an article for Windows Phone on roughly this topic, so the codeshould give you some insights.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900