导航:
论坛 -> DELPHI技术
斑竹:liumazi,sephil
作者:
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;
----------------------------------------------
-
作者:
2023/9/13 22:36:23
1楼:
以上代码没有问题。 出错的: EOleException 说明一个引用的OLE没有注意什么的,应该是其它位置的代码出的错。不然你自己仅写这个简单的代码,也不会出错。
----------------------------------------------
-
作者:
2023/9/14 22:36:15
2楼:
就是不知道哪里遇到冲突了
----------------------------------------------
-
作者:
lsuper (lsuper)
★☆☆☆☆
-
盒子活跃会员
2023/9/15 0:56:46
3楼:
代码是在主线程(UI 线程)中执行的?譬如 放 FormShow 里
----------------------------------------------
-
作者:
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
作者:
2023/9/15 21:36:25
4楼:
@lsuper,是的,在formshow里面
----------------------------------------------
-
作者:
2023/9/20 22:08:24
5楼:
在 OnFormShow 里面执行的代码,是 Delphhi 的主线程执行的。 你的 Win10show 里面的代码,NotificationCenter1.PresentNotification 这个,具体干了什么事情?看错误提示,它里面的具体执行,可能是其它的线程。假设调用了 WINDOWS 提供的 OLE 或者 COM,那你需要加上 CoInitialize
----------------------------------------------
-