Solved

Accessing Windows.h in C#

Posted on 2007-03-30
3
658 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
visual Basic Net vs c# net 8 54
Problem to picture file 3 40
Chat Room 1 26
Copy/Clone an object. 9 13
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now