Question : SHGetPathFromIDList(IntPtr,  String^); API in VC++.net Not working please tell me where i am wrong

i am using SHGetPathFromIDList(IntPtr in, String^ path)  API  in VC++.Net i have declared for cutomized in my Apllication for .net as

[DllImport("Shell32.Dll")]
static bool SHGetPathFromIDList(IntPtr pidl, String^ pszPath);

the frist parameter is the copied address value of WParam that i have find using WndProc function


now i am giving code snip


virtual void WndProc( Message% m ) override  
                         {
                               switch(m.Msg)
                               {
                               case (int) WM_SHNOTIFY:
                                     {
                                          NotificationReceipt(m.WParam, m.LParam);
                                          break;
                                     }
                               }

                              Form::WndProc( m );
                        }



Then


public: void NotificationReceipt(IntPtr WParam, IntPtr LParam)
                    {
                           String^ sOut;
                              SHNOTIFYSTRUCT shns;
                              int nTemp = LParam.ToInt32();
                              sOut = SHNotify_GetEventStr(LParam);
                              CopyMemory(shns,WParam, sizeof(SHNOTIFYSTRUCT));
                                                      
                              string sDisplayname;
                                    
                              String^ filePath = GetPathFromPidl(shns.dwItem1);

                               }

then after that



public: static String^ GetPathFromPidl(IntPtr Pidl)
            {
            
                  String^ Path;
                  Path = gcnew String('\0', 255);

                  
                  bool b=SHGetPathFromIDList( Pidl, Path);
            
                  return Path;
            }


the SHGetPathFromIDList api is returning value true but no path retrieve no value retrieve only blank

p;ease tell me where i am wrong

Answer : SHGetPathFromIDList(IntPtr,  String^); API in VC++.net Not working please tell me where i am wrong

it's worked.
Random Solutions  
 
programming4us programming4us