Subject:
Re: [ruby-ffi] Function 'LoadIconMetric' not found in [kernel32, user32, gdi32, comctl32] (FFI::NotFoundError)
From:
bawng@intoxicated.co.za
Date:
9/28/13 6:58 PM
To:
ruby-ffi@googlegroups.com

To be honest, I thought all details needed were already included, I should have included the error I put in the topic in my post body as well, maybe you didn't notice it in the topic.

The error says: Function 'LoadIconMetric' not found in [kernel32, user32, gdi32, comctl32] (FFI::NotFoundError)

From that I thought it would be clear I am using ffi_lib to load those 4 DLLs, comctl32.dll is supposed to contain LoadIconMetric but in order to use that function it needs to be loaded with the correct manifest specifying version 6 like my quoted C++ sample code explained.
// we need commctrl v6 for LoadIconMetric()
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#pragma comment(lib, "comctl32.lib")

From what I can tell after searching the ffi source code and documentation, it does not appear to have any support for Windows manifests. I have even tried creating manual ffi_c.so.manifest file, but it does not get used. This is the first time I have had to learn about manifests and how DLLs can hide functions depending on the manifest version it was loaded with, I usually avoid Windows specific programming in general.

The best workaround I can think of is compiling my own custom proxy DLL written in C++ which defines that manifest with the #pragma line quoted above, load that DLL with FFI and use it to access the correct Windows API function.

It would be great if FFI could support manifests in future, so that you do not have to compile a proxy DLL file like this.

Thanks,
bawNg


On Sunday, September 29, 2013 12:31:03 AM UTC+2, Jon wrote:
You've fallen prey to a great way to not get a response; making one work harder in order to help.

Always provide a minimal failing code snippet. Laziness can be great, but you're being too lazy ;)

That said, assuming something like pestudio or dependency walker failed to find these symbols, could LoadIconMetric be a macro wrapping another API? I don't have vc++ or the platform sdk on this machine to check, but spelunking the headers might get you unstuck since

http://msdn.microsoft.com/en-us/library/windows/desktop/bb775701%28v=vs.85%29.aspx

is minimally helpful.


On Sat, Sep 28, 2013 at 2:46 PM, <ba...@intoxicated.co.za> wrote:
Hello ruby-ffi,

I am attempting to attach to the LoadIconMetric Windows API function which is part of comctl32. The function is not found and so can never be attached.

The following 3 lines are taken from the top of one of the Microsoft VC++ sample projects cpp files:
// we need commctrl v6 for LoadIconMetric()
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#pragma comment(lib, "comctl32.lib")

 This function is required in order to make use of the Windows system tray icon API. I really hope there is a simple solution to this problem.

Thanks,
bawNg

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.