Click here to Skip to main content
15,907,874 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralJohn, Not sure if this will help Pin
E.L. Golpe10-Nov-03 5:59
E.L. Golpe10-Nov-03 5:59 
Generalflicker on resizing tabcontrols Pin
siegnagel7-Nov-03 0:45
siegnagel7-Nov-03 0:45 
GeneralMaybe same class of problem as this?? Pin
E.L. Golpe10-Nov-03 6:02
E.L. Golpe10-Nov-03 6:02 
GeneralKeyCodeV2 Pin
kersyanti6-Nov-03 20:10
kersyanti6-Nov-03 20:10 
QuestionManaged C++ server side executables ? Pin
Jerry Evans6-Nov-03 8:51
Jerry Evans6-Nov-03 8:51 
AnswerRe: Managed C++ server side executables ? Pin
leppie6-Nov-03 9:50
leppie6-Nov-03 9:50 
GeneralRe: Managed C++ server side executables ? Pin
Jerry Evans8-Nov-03 7:39
Jerry Evans8-Nov-03 7:39 
GeneralFrom MSDN Magazine, Sometime in the past... Pin
E.L. Golpe10-Nov-03 6:07
E.L. Golpe10-Nov-03 6:07 
One of the major benefits of Microsoft® .NET is that it provides a language-independent development system. You can write classes in Visual Basic®, C++, C#—whatever—and use them in other languages; you can even derive from classes in a different language. But what happens when you want to call some old-school unmanaged DLL? You have to somehow translate .NET objects into the structs, char*'s, and function pointers C expects. In techno lingo, your parameters must be marshaled. Marshaling is a big topic, but luckily you don't have to know much to get the job done.
To call a DLL function from C#, first you must provide a declaration, something programmers using Visual Basic have been doing for years. In C#, it's DllImport:

using System.Runtime.InteropServices; // DllImport
public class Win32 {
[DllImport("User32.Dll")]
public static extern void SetWindowText(int h, String s);
}

In C#, you use DllImport to tell the compiler where the entry point lives and bundle your wrapper functions inside a class. You can give this class any name you like; I chose Win32. You can even put the class inside a namespace. To compile Win32API.cs, type:

csc /t:library /out:Win32API.dll Win32API.cs

Now you have a Win32API.dll you can use in any C# project.

using Win32API;
int hwnd = // get it...
String s = "I'm so cute."
Win32.SetWindowText(hwnd, s);



Practice sesquipedalianism! Wink | ;)
GeneralRe: From MSDN Magazine, Sometime in the past... Pin
Jerry Evans10-Nov-03 6:55
Jerry Evans10-Nov-03 6:55 
GeneralRe: From MSDN Magazine, Sometime in the past... Pin
Heath Stewart10-Nov-03 7:37
protectorHeath Stewart10-Nov-03 7:37 
GeneralRe: From MSDN Magazine, Sometime in the past... Pin
Jerry Evans10-Nov-03 8:01
Jerry Evans10-Nov-03 8:01 
GeneralRe: From MSDN Magazine, Sometime in the past... Pin
Heath Stewart10-Nov-03 9:33
protectorHeath Stewart10-Nov-03 9:33 
GeneralRe: Managed C++ server side executables ? Pin
Heath Stewart10-Nov-03 6:09
protectorHeath Stewart10-Nov-03 6:09 
GeneralRe: Managed C++ server side executables ? Pin
Jerry Evans10-Nov-03 6:57
Jerry Evans10-Nov-03 6:57 
GeneralSetup Program Pin
kersyanti5-Nov-03 23:23
kersyanti5-Nov-03 23:23 
GeneralRe: Setup Program Pin
Mike Dimmick6-Nov-03 2:17
Mike Dimmick6-Nov-03 2:17 
Questionhow to delete one file in network share folder with .NET Pin
don7cry5-Nov-03 16:06
don7cry5-Nov-03 16:06 
AnswerRe: how to delete one file in network share folder with .NET Pin
Al Gardner7-Nov-03 1:34
Al Gardner7-Nov-03 1:34 
AnswerRe: how to delete one file in network share folder with .NET Pin
jparsons8-Nov-03 12:12
jparsons8-Nov-03 12:12 
GeneralProblems with Exception Management Application Block Pin
Andy Hochstetler5-Nov-03 16:06
Andy Hochstetler5-Nov-03 16:06 
GeneralDoEvents kill Callback - Help needed! Pin
Vacationistas5-Nov-03 9:07
Vacationistas5-Nov-03 9:07 
General.NET Version 7.0 and 7.1 incompatability Pin
Showme805-Nov-03 4:48
Showme805-Nov-03 4:48 
GeneralRe: .NET Version 7.0 and 7.1 incompatability Pin
J. Dunlap5-Nov-03 8:42
J. Dunlap5-Nov-03 8:42 
GeneralThats easy.. Pin
E.L. Golpe10-Nov-03 6:20
E.L. Golpe10-Nov-03 6:20 
GeneralBeginner's Localization question Pin
Anonymous4-Nov-03 6:03
Anonymous4-Nov-03 6:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.