我想prevent从钉扎我的.NET应用程序到任务栏的用户。我发现在旧的新的一些code事情的做到了这一点。但是,它是在C ++中。
I am trying to prevent the user from pinning my .NET app to the taskbar. I've found some code on the Old New Thing that does just that. However, it is in C++.
#include <shellapi.h>
#include <propsys.h>
#include <propkey.h>
HRESULT MarkWindowAsUnpinnable(HWND hwnd)
{
IPropertyStore *pps;
HRESULT hr = SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&pps));
if (SUCCEEDED(hr)) {
PROPVARIANT var;
var.vt = VT_BOOL;
var.boolVal = VARIANT_TRUE;
hr = pps->SetValue(PKEY_AppUserModel_PreventPinning, var);
pps->Release();
}
return hr;
}
BOOL
OnCreate(HWND hwnd, LPCREATESTRUCT lpcs)
{
MarkWindowAsUnpinnable(hwnd);
return TRUE;
}
我有很少的运气将其转换为C#。有人可以帮忙吗?
I am having very little luck converting it to c#. Can someone help?
您也可以下载Windows您需要翻译的code在帖子中为C#API code包有必要的P / Invoke调用。
You can download the Windows API Code Pack which has the necessary p/invoke calls you need to translate the code in your post to C#.
既可以使用库中的全部或找到您所需要(搜索它 SHGetPropertyStoreForWindow
,然后它的其他依赖关系)的具体要求和定义。
Either use the library in whole or find the specific calls and definitions you require (search it for SHGetPropertyStoreForWindow
and then its other dependencies).
上一篇:使用[NSFileManager URLForUbiquiyContainerIdentifier:]和使用[NSFileManager ubiquiyIdentityToken]的主要区别是什么?区
下一篇:处理应用程序:Open URL:SourceApplication:在iOS应用程序中打开文件应用程序、文件、Open、URL