Click here to Skip to main content
15,908,775 members
Home / Discussions / C#
   

C#

 
GeneralRe: help me pls~~ Pin
Bernhard22-Oct-01 4:09
Bernhard22-Oct-01 4:09 
QuestionHow to get disk label? Pin
21-Oct-01 22:10
suss21-Oct-01 22:10 
Question:confused: Why do the Docking not work? Pin
aner_glx17-Oct-01 9:35
aner_glx17-Oct-01 9:35 
AnswerRe: :confused: Why do the Docking not work? Pin
22-Oct-01 1:06
suss22-Oct-01 1:06 
GeneralRe: :confused: Why do the Docking not work? Pin
aner_glx23-Oct-01 13:36
aner_glx23-Oct-01 13:36 
GeneralLPVoid and Beta2 Pin
A.A.16-Oct-01 10:54
A.A.16-Oct-01 10:54 
GeneralRe: LPVoid and Beta2 Pin
Eric Gunnerson (msft)17-Oct-01 9:54
Eric Gunnerson (msft)17-Oct-01 9:54 
GeneralRe: LPVoid and Beta2 Pin
A.A.19-Oct-01 15:30
A.A.19-Oct-01 15:30 
I tried using IntPtr using several tricks none of which works. What I am trying to do is call a win32 api, using C#. I did what I wanted easily in managed C++ with the features I wanted, though I thought it would be better if I can get it in the same project and hence use C# rather than using an external dll.

Lets take an example NetServerEnum, which I adapted from here to use beta2:

--------------
[DllImport("netapi32.dll")]
unsafe private static extern uint NetServerEnum(
[MarshalAs(UnmanagedType.LPWStr)] string ServerName,
uint level,
//In my test I try to change this next line
//with something appropriate, though no LPVoid
//I tried some of the other types with no
//success
[MarshalAs(UnmanagedType.LPVoid)]uint* bufptr, uint prefmaxlen,
ref uint entriesread,
ref uint totalentries,
uint servertype,
[MarshalAs(UnmanagedType.LPWStr)] string domain,
uint resume_handle);
--------------

At the end of the day I get one of two results depending how I approach it.

A.It compiles, but the function returns error 87 which stands for 'The parameter is incorrect.'

B.An exception
--------------
Unhandled Exception: System.Runtime.InteropServices.MarshalDirectiveException: C
annot marshal parameter #3: Invalid managed/unmanaged type combination pointers must be paired with LPVoid).
--------------


I made a managed C++ component to do what I want(didn't take more than a couple of minutes), but was trying to compact things by not using managed C++ if I don't have. And since something similar was done in beta1 I was thinking it should be easily done in beta2, though I am not sure what I am overlooking here.

Thanks.
GeneralRe: LPVoid and Beta2 Pin
Eric Gunnerson (msft)22-Oct-01 9:32
Eric Gunnerson (msft)22-Oct-01 9:32 
GeneralRe: LPVoid and Beta2 Pin
A.A.24-Oct-01 6:50
A.A.24-Oct-01 6:50 
Questionhow do i create a new line in a text Box? Pin
15-Oct-01 14:30
suss15-Oct-01 14:30 
AnswerRe: how do i create a new line in a text Box? Pin
16-Oct-01 9:58
suss16-Oct-01 9:58 
GeneralAbout Path Select Dialog Pin
aner_glx15-Oct-01 11:57
aner_glx15-Oct-01 11:57 
GeneralRe: About Path Select Dialog Pin
Iverson22-Oct-01 14:16
Iverson22-Oct-01 14:16 
GeneralRe: About Path Select Dialog Pin
aner_glx23-Oct-01 13:41
aner_glx23-Oct-01 13:41 
GeneralInterfacing between HTML and Windows Forms Pin
15-Oct-01 4:18
suss15-Oct-01 4:18 
QuestionWeb Service to Windows Forms communication HELP!? Pin
15-Oct-01 0:25
suss15-Oct-01 0:25 
GeneralQuestion regarding C# Pin
12-Oct-01 7:39
suss12-Oct-01 7:39 
GeneralRe: Question regarding C# Pin
16-Oct-01 10:00
suss16-Oct-01 10:00 
GeneralRe: Question regarding C# Pin
Nish Nishant23-Oct-01 23:21
sitebuilderNish Nishant23-Oct-01 23:21 
GeneralC# developers Pin
7-Nov-01 5:44
suss7-Nov-01 5:44 
GeneralSet, Get window position Pin
EZ11-Oct-01 9:57
EZ11-Oct-01 9:57 
GeneralWebDAV Pin
10-Oct-01 4:38
suss10-Oct-01 4:38 
GeneralRe: WebDAV Pin
Anonymous16-Aug-02 15:46
Anonymous16-Aug-02 15:46 
GeneralWhen will .NET framework shipped with Windows Pin
8-Oct-01 19:58
suss8-Oct-01 19:58 

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.