DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: haibei
今日帖子: 7
在线用户: 5
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 zhouying (zy) ★☆☆☆☆ -
盒子活跃会员
2023/9/13 22:17:50
标题:
应用程序调用一个已为另一线程整理的接口 浏览:283
加入我的收藏
楼主: 请教下各位我在formshow加了个win10的状态框提示代码,运行时出现了这个错误对话框,一般是啥原因呢?
Project xxx.exe raised exception class EOleException with message'应用程序调用一个已为另一线程整理的接口'

 if  TOSVersion.Check(6, 2) then
          begin
          Win10show(Appname,'检测到当前数据库有更新','您可以点击工具栏第四个带小蓝点的按钮完成更新。');
          end

procedure TForm1.Win10show(const name, title, memo: string);
var
  MyNotification: TNotification;
begin
  MyNotification := NotificationCenter1.CreateNotification;
  try
    MyNotification.name := name;
    MyNotification.title := title;
    MyNotification.AlertBody := memo;
    NotificationCenter1.PresentNotification(MyNotification);
  finally
    MyNotification.Free;
  end;
end;
----------------------------------------------
-
作者:
男 net1999 (好人) ★☆☆☆☆ -
普通会员
2023/9/13 22:36:23
1楼: 以上代码没有问题。
出错的: EOleException  说明一个引用的OLE没有注意什么的,应该是其它位置的代码出的错。不然你自己仅写这个简单的代码,也不会出错。
----------------------------------------------
-
作者:
男 zhouying (zy) ★☆☆☆☆ -
盒子活跃会员
2023/9/14 22:36:15
2楼: 就是不知道哪里遇到冲突了
----------------------------------------------
-
作者:
男 lsuper (lsuper) ★☆☆☆☆ -
盒子活跃会员
2023/9/15 0:56:46
3楼: 代码是在主线程(UI 线程)中执行的?譬如 放 FormShow 里
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2023/9/15 0:58:00
3楼: create a new project (in blank) with just your "Notification" test
and install it for test!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 zhouying (zy) ★☆☆☆☆ -
盒子活跃会员
2023/9/15 21:36:25
4楼: @lsuper,是的,在formshow里面
----------------------------------------------
-
作者:
男 pcplayer (pcplayer) ★☆☆☆☆ -
普通会员
2023/9/20 22:08:24
5楼: 在 OnFormShow 里面执行的代码,是 Delphhi 的主线程执行的。

你的 Win10show 里面的代码,NotificationCenter1.PresentNotification 这个,具体干了什么事情?看错误提示,它里面的具体执行,可能是其它的线程。假设调用了 WINDOWS 提供的 OLE 或者 COM,那你需要加上 CoInitialize
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行62.5毫秒 RSS