.net - How to retrieve IFileOpenDialog interface in C# from IUnknown_QueryService SID_SExplorerBrowserFrame? -


i'm trying hook file dialogs in custom namespace extensions project. done in c#.

i'm trying follow post: http://blogs.msdn.com/b/winsdk/archive/2015/03/24/how-to-register-for-file-dialog-notifications-from-shell-namespace-extension.aspx

in c++ works, , ifileopendialog interface: done under setsite method:

hresult hr = iunknown_queryservice(m_punksite, sid_sexplorerbrowserframe, iid_ppv_args(&m_fileopendialog)); 

where m_fileopendialog ifileopendialog

i'm trying same in c#, doesn't work...

i've tried several ways:

filedialognative.ifileopendialog o2 = marshal.getobjectforiunknown(m_punksite) filedialognative.ifileopendialog; 

o2 null.

i've tried

intptr ptr; guid g = new guid("000214f1-0000-0000-c000-000000000046"); int rc = marshal.queryinterface(m_punksite, ref g, out ptr); 

this succeeds, have no idea how convert "ptr" required interface.

any appriciated.

**update comment **,

i tried doing this:

[dllimport("shlwapi.dll")] internal static extern int iunknown_queryservice(intptr punk, ref guid guidservice, ref guid riid, out intptr ppvout);   guid g = new guid("000214f1-0000-0000-c000-000000000046"); // sid_sexplorerbrowserframe guid g2 = new guid("d57c7288-d4ad-4768-be02-9d969532d960"); // ifileopendialog  intptr pp; int rrc =  win32.iunknown_queryservice(punksite, ref g, ref g2, out pp);  filedialognative.ifileopendialog o2 = marshal.getobjectforiunknown(pp) filedialognative.ifileopendialog; 

this worked!!! thanks!!

so, hans passant, understood "iunknown_queryservice" not same tried.

i've managed catch interface in following way:

[dllimport("shlwapi.dll")] internal static extern int iunknown_queryservice(intptr punk, ref guid guidservice, ref guid riid, out intptr ppvout);   guid g = new guid("000214f1-0000-0000-c000-000000000046"); // sid_sexplorerbrowserframe guid g2 = new guid("d57c7288-d4ad-4768-be02-9d969532d960"); // ifileopendialog  intptr pp; int rrc =  win32.iunknown_queryservice(punksite, ref g, ref g2, out pp);  filedialognative.ifileopendialog dlg = marshal.getobjectforiunknown(pp) filedialognative.ifileopendialog; marshal.release(pp); 

then, able use dlg :)


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -