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

.NET (Core and Framework)

 
GeneralServer Error in '/myaspx' Application Pin
Orkun GEDiK27-Dec-01 8:55
Orkun GEDiK27-Dec-01 8:55 
QuestionWhat is .NET???? Pin
Jon Newman20-Dec-01 8:18
Jon Newman20-Dec-01 8:18 
AnswerRe: What is .NET???? Pin
Fazlul Kabir20-Dec-01 8:25
Fazlul Kabir20-Dec-01 8:25 
QuestionDefining assignment operator on a managed C++ class? Pin
DVryce19-Dec-01 3:30
DVryce19-Dec-01 3:30 
General.NET assembly question Pin
C. Kapturek19-Dec-01 1:01
C. Kapturek19-Dec-01 1:01 
GeneralRe: .NET assembly question Pin
C. Kapturek19-Dec-01 3:01
C. Kapturek19-Dec-01 3:01 
GeneralConverting .NET String to something usable by old unsafe C/C++ Code Pin
DVryce17-Dec-01 7:39
DVryce17-Dec-01 7:39 
GeneralRe: Converting .NET String to something usable by old unsafe C/C++ Code Pin
James T. Johnson17-Dec-01 8:05
James T. Johnson17-Dec-01 8:05 
You can use one of two things, either the StringBuilder or you can marshal the string data.

If you need a buffer of some sort, like you need for getting a special folder you need to use StringBuilder

Code courtesy Tomas Restrepo
[ DllImport("shell32.dll") ]
private static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, StringBuilder lpszPath, int nFolder, bool fCreate);

StringBuilder dirPath = new StringBuilder(256,1024);
bool res = SHGetSpecialFolderPath(IntPtr.Zero, dirPath, CSIDL_APPDATA, true);


If you just need to pass a string in to a function but do not modify it use marshalling. I don't know what will happen if you try to modify it, it could reflect the change, or it could blow up on you.

From Inside C# by Tom Archer
[DllImport("user32.dll", CharSet=CharSet.Unicode)]
static extern int MessageBox(
		IntPtr hWnd, 
		[MarshalAs(UnmanagedType.LPWStr)]
		string msg,
		[MarshalAs(UnmanagerType.LPWStr)]
		string caption,
		int type
);

MessageBox(0, "Hello, World!", "This is called from a C# app!", 0);


Both code snippets are untested, but should demonstrate how to do it. I made a minor change in Tom Archer's code and that was to reflect that handles, such as HWNDs should be IntPtr's instead of int's.

HTH,

James

Sonork ID: 100.11138 - Hasaki
and a digital cookie (not chocolate chip, its computer chip) goes to whoever can be the first to tell me what Hasaki means. I know someone registered on here can tell me Smile | :)
GeneralRe: Converting .NET String to something usable by old unsafe C/C++ Code Pin
DVryce17-Dec-01 9:38
DVryce17-Dec-01 9:38 
GeneralRe: Converting .NET String to something usable by old unsafe C/C++ Code Pin
James T. Johnson17-Dec-01 16:15
James T. Johnson17-Dec-01 16:15 
GeneralBig time help needed! Pin
GaryGa14-Dec-01 21:23
GaryGa14-Dec-01 21:23 
GeneralRe: Big time help needed! Pin
James T. Johnson17-Dec-01 2:28
James T. Johnson17-Dec-01 2:28 
GeneralData-Aware Classes in vb.net Pin
rashmirao11-Dec-01 9:51
rashmirao11-Dec-01 9:51 
QuestionMessageBox on the client? Pin
Carolina10-Dec-01 2:35
Carolina10-Dec-01 2:35 
AnswerRe: MessageBox on the client? Pin
James T. Johnson14-Dec-01 7:30
James T. Johnson14-Dec-01 7:30 
GeneralRe: MessageBox on the client? ... and also a confirm dialogue? Pin
Carolina16-Dec-01 23:04
Carolina16-Dec-01 23:04 
GeneralRe: MessageBox on the client? ... and also a confirm dialogue? Pin
James T. Johnson17-Dec-01 2:22
James T. Johnson17-Dec-01 2:22 
GeneralThink What is the Reality Pin
6-Dec-01 22:55
suss6-Dec-01 22:55 
GeneralRelease candidate form error Pin
jkgh3-Dec-01 5:15
jkgh3-Dec-01 5:15 
Generalasp.net Pin
ov2-Dec-01 23:04
ov2-Dec-01 23:04 
QuestionHow to create circular references between DLLs/assemblies? Pin
Brian Morearty2-Dec-01 7:55
Brian Morearty2-Dec-01 7:55 
GeneralHelp with a .NET app architecture... Pin
Defcon1-Dec-01 1:37
Defcon1-Dec-01 1:37 
GeneralHelp with winform designer Pin
Brian Olej30-Nov-01 18:31
Brian Olej30-Nov-01 18:31 
GeneralVS .NET bug Pin
Matt.W.29-Nov-01 14:46
Matt.W.29-Nov-01 14:46 
GeneralRe: VS .NET bug Pin
Brian Olej30-Nov-01 10:00
Brian Olej30-Nov-01 10:00 

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.