joe_pool_is Posted December 24, 2005 Posted December 24, 2005 There is a C++ function that I have used in Borland called SHGetSpecialFolderLocation that is actually a Microsoft API call. I'm looking for something similar to this in C#. Does it exist? Can I still use C++ APIs in C#? Quote Avoid Sears Home Improvement
HJB417 Posted December 24, 2005 Posted December 24, 2005 And an example of using a c++ api in c# [DllImport("shell32.dll", SetLastError=true)] private static extern uint SHGetSpecialFolderLocation(IntPtr hwndOwner, int nFolder, out IntPtr ppidl); /// <summary> /// Retrieves a pointer to the <b>ITEMIDLIST</b> structure of a special folder. /// </summary> /// <param name="hwndOwner">Handle to the owner window the client should /// specify if it displays a dialog box or message box.</param> /// <param name="folder">The folder of interest.</param> /// <returns>A pointer to the <b>ITEMIDLIST</b> structure of a special folder.</returns> /// <exception cref="Win32Exception">When the the unmanaged function returns a failure error code.</exception> public static IntPtr GetSpecialFolderLocation(IntPtr hwndOwner, Environment.SpecialFolder folder) { IntPtr ppidl; uint result = SHGetSpecialFolderLocation(hwndOwner, (int) folder, out ppidl); if(result != 0) throw new Win32Exception(); return ppidl; } Using P/Invoke to Access Win32 APIs Quote
joe_pool_is Posted December 24, 2005 Author Posted December 24, 2005 Fabulous! Thanks. I was just looking into the thread "Implementing the IActiveDesktop in VB.NET" in the tutorial section, and it is very long! I'll look into your version first. Quote Avoid Sears Home Improvement
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.