Solved

Accessing Windows.h in C#

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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