Max*_*ich 2 c# vb.net api service winapi
总而言之,我试图将一些功能添加到作为Windows服务运行的自定义更新程序中.我遇到了一些问题,我试图更新的应用程序可能正在运行,如果是,我需要执行一些自定义操作.
我遇到的问题是EnumDesktopWindows api调用只返回在本地系统上下文中运行的进程.
现在,这对我来说至关重要的是为什么要这样做等等(我想 - 虽然希望进一步解释).
但是,如何通过服务实现此功能?
这是我正在使用的代码的基础知识:
public static IntPtr[] EnumDesktopWindows()
{
WinAPI._desktopWindowHandles = new List<IntPtr>();
WinAPI.EnumDelegate enumfunc = new WinAPI.EnumDelegate(EnumWindowsCallBack);
IntPtr hDesktop = IntPtr.Zero; // current desktop
bool success = WinAPI.EnumDesktopWindows(hDesktop, enumfunc, IntPtr.Zero);
if (success)
{
IntPtr[] handles = new IntPtr[_desktopWindowHandles.Count];
_desktopWindowHandles.CopyTo(handles);
return handles;
}
else
{
int errorCode = Marshal.GetLastWin32Error();
string errorMessage = String.Format("EnumDesktopWindows failed with code {0}.", errorCode);
throw new Exception(errorMessage);
}
}
Run Code Online (Sandbox Code Playgroud)
可能是因为我把这一切都搞错了,问题就出现了?:
IntPtr hDesktop = IntPtr.Zero;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1791 次 |
| 最近记录: |