dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] Re: RE : RE : RE : RE : RE : RE : RE : [Pnet-developer


From: Rhys Weatherley
Subject: [Pnet-developers] Re: RE : RE : RE : RE : RE : RE : RE : [Pnet-developers] System.NotImplementedException when implementing Environment.GetSpecialFolder
Date: Fri, 25 Jul 2003 08:53:30 +1000
User-agent: KMail/1.4.3

On Thursday 24 July 2003 11:33 pm, Yannis BRES wrote:

> [DllImport("shell32.dll",CallingConvention=CallingConvention.Winapi)]
> [MethodImpl(MethodImplOptions.PreserveSig)]
> extern private static Int32 SHGetFolderPath
>   (IntPtr hwndOwner, int nFolder, IntPtr hToken,
>   uint dwFlags, [MarshalAsAttribute(UnmanagedType.LPTStr)] string path);

You will probably need to allocate a buffer using "Marshal.AllocHGlobal" and 
pass it as the "path" parameter.  Then use "PtrToStringAnsi" to convert it 
into a C# string.  Also, name the function "SHGetFolderPathA" to explicitly 
pick up the ANSI version.

MS'es engine does a lot of things "by magic" that we don't currently support, 
although we will eventually.  At the moment, you have to be a little more 
explicit when calling Win32 functions via PInvoke.  e.g.

[DllImport("shell32.dll",CallingConvention=CallingConvention.Winapi)]
extern private static Int32 SHGetFolderPathA
   (IntPtr hwndOwner, int nFolder, IntPtr hToken, uint dwFlags, IntPtr path);

Cheers,

Rhys.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]