if (GetOpenFileNameEx(ref t))
MessageBox.Show(Marshal.PtrToStringUni(t.lpstrFile));
Marshal.FreeHGlobal(t.lpstrFile);
....
public struct LPOPENFILENAMEEX
{
public int lStructSize;
public IntPtr hwndOwner;
public IntPtr hInstance;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrFilter;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrCustomFilter;
public int nMaxCustFilter;
public int nFilterIndex;
public IntPtr lpstrFile;
public int nMaxFile;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrFileTitle;
public int nMaxFileTitle;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrInitialDir;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrTitle;
public int Flags;
public short nFileOffset;
public short nFileExtension;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrDefExt;
public IntPtr lCustData;
public IntPtr lpfnHook;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpTemplateName;
// Extended fields
public int dwSortOrder;
public int ExFlags;
}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.