Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Accessing Windows.h in C#

Posted on 2007-03-30
3
663 Views
Last Modified: 2013-12-17
In MS Visual C#, what's the equivalent of

"#include <windows.h>" (from MS Visual C++)

The "#include" command isn't recognized and I want to do things with

USHORT* and malloc and what not.  Can one do such a thing?
0
Comment
Question by:raw_enha
  • 2
3 Comments
 
LVL 25

Expert Comment

by:dstanley9
ID: 18824786
Not in C#.  Those are C++ language constructs.  What are you trying to do?
0
 

Author Comment

by:raw_enha
ID: 18824989
Well, I have some code that I wanted to convert to C#, but it heavily uses pointers and commands such as malloc and free.

would i be able to write it in C++ and access the code through some sort of DLL or COM object or something?  I'm new to C#, so I'm not sure whats possible.
0
 
LVL 25

Accepted Solution

by:
dstanley9 earned 500 total points
ID: 18825014
You can write .NET-visible classes using C++.NET that internally use memcpy and other "unsafe" methods.  Your public interface, however, needs to use CLR-compliant types - strings, integers, floats, dates, etc.  You can also write C++ DLLs that expose C-style methods that can be called using p-invoke.

I would avoid using COM unless you have to.  
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question