Importing specific ( in my case - Themes.ThemesService.ThemesEnabled ) function / procedure in runetime in Delphi
I think subject tells everything ...
I need this method only. No need to waste about 6Mb of included unit if only thing I need is one开发者_运维百科 method from that unit ( Themes ) ...
I was thinking of UxTheme unit, but it did not contain proper function. What Windows DLL do I need to import and what API function this method stands for?
Thanks.
P.S. Question is intended to cover not only this particular method, but others too as I will need to do same in MSXML and MM units ...
@HX_unbanned, apparently you're a little confused. because adding the themes unit to your project only increment the size of the exe in 321 kb aprox. anyway if you want to check if you application is themed (themesEnabled) manually you must follow the next steps.
1) check the version of the comctl32.dll library (must be major or equal to 6)
2) load the uxtheme.dll library
3) import the IsThemeActive
and IsAppThemed
functions.
4) check the values of theses functions (both must be true)
check this sample
function ThemesEnabled :Boolean;
const
ComCtlVersionIE6 = $00060000;
var
ThemeLib : THandle;
IsThemeActive : function: Boolean; stdcall;
IsAppThemed : function: Boolean; stdcall;
begin
Result:=GetFileVersion('comctl32.dll')>=ComCtlVersionIE6;
if not Result then exit;
ThemeLib := LoadLibrary('uxtheme.dll');
try
if ThemeLib > 0 then
begin
IsAppThemed := GetProcAddress(ThemeLib, 'IsAppThemed');
IsThemeActive := GetProcAddress(ThemeLib, 'IsThemeActive');
Result:=IsAppThemed and IsThemeActive;
end
else
Result:=False;
finally
FreeLibrary(ThemeLib);
end;
end;
精彩评论