Solved

Accessing Windows.h in C#

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

Title # Comments Views Activity
Wav problem 4 25
rest webservice call over https via c# 6 37
Capture logon name 13 70
No Data for DropDown List 2 22
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

9 Experts available now in Live!

Get 1:1 Help Now