在 Delphi 的 runetime 中导入特定的(在我的例子中 - Themes.ThemesService.ThemesEnabled )函数/过程

发布于 2024-09-02 01:47:44 字数 230 浏览 4 评论 0原文

我认为主题说明了一切......

我只需要这个方法。如果我只需要该单元(主题)中的一种方法,则无需浪费大约 6Mb 的包含单元...

我正在考虑 UxTheme 单元,但它不包含正确的功能。我需要导入什么Windows DLL以及这个方法代表什么API函数?

谢谢。

PS 问题不仅旨在涵盖此特定方法,还涵盖其他方法,因为我需要在 MSXML 和 MM 单元中执行相同的操作...

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 ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光的暖冬 2024-09-09 01:47:44

@HX_unbanned,显然你有点困惑。因为将主题单元添加到项目中只会增加 exe 的大小,大约为 321 kb。无论如何,如果您想手动检查您的应用程序是否有主题(themesEnabled),您必须按照以下步骤操作。

1) 检查 comctl32.dll 库的版本(必须是主要或等于 6)

2) 加载 uxtheme.dll 库

3) 导入 IsThemeActiveIsAppThemed 函数。

4)检查这些函数的值(两者都必须为真)

检查此示例

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;

@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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文