dotgnu-pnet
[Top][All Lists]
Advanced

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

Re: [Pnet-developers] System.NotImplementedException when implementing E


From: Gopal V
Subject: Re: [Pnet-developers] System.NotImplementedException when implementing Environment.GetSpecialFolder
Date: Thu, 24 Jul 2003 21:36:53 +0530
User-agent: Mutt/1.2.5i

If memory serves me right, Yannis BRES wrote:
>      Great.  When implementing everything at the C# level, the code is only
> a few line...

yes, btw you should use

if(Environment.OSVersion.Platform != (PlatformID)128)
{
}

because of compiler errors when someone (like Niel Cawse) compiles
it with MS CSC :)

> // From my not so good/common sense:
> [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);

Also are you sure shell32.dll is the right one ?

I'm not too sure about the path thing .... are you sure you have to use
a normal param ?. ie it is a value result parameter so you should use 
"ref" , shouldn't you ?. And it should be pre-allocated too ?

That makes it a very complicated function to handle... PInvoke does not
know what to free() and what not to ... so the idea to avoid memory leaks
in pnet, is attached :) .

> // From http://www.dotnet247.com/247reference/msgs/2/11935.aspx
> [DllImport("SHFolder", CharSet = CharSet.Unicode)]
> public static extern int SHGetFolderPath
>   (int hwndOwner, int nFolder, int hToken, int dwFlags,
>   [MarshalAsAttribute(UnmanagedType.LPTStr)] string pszPath);

int ? ... that's bad :)

> >From http://www.codeproject.com/csharp/csdoesshell1.asp
> [DllImport("shell32.dll")]
> public static extern Int32 SHGetFolderPath
>   (IntPtr hwndOwner, Int32 nFolder, IntPtr hToken,
>   UInt32 dwFlags, StringBuilder pszPath);

StringBuilder is wrong !!

Gopal
-- 
The difference between insanity and genius is measured by success

Attachment: pinvoke.tgz
Description: GNU Zip compressed data


reply via email to

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