【HSP3】HSPでショートカットにAppUserModelID(Application Identity)を設定してみる

エラー処理なし

エラー処理なし

  • hk1v
  • 2013/12/4 21:41
  • タグ:
  • タグはありません
#packopt name "test1"

#uselib "Propsys"
#func InitPropVariantFromStringVector "InitPropVariantFromStringVector" wptr, int, sptr

#define CLSID_ShellLink "{00021401-0000-0000-C000-000000000046}"
#define IID_IShellLink "{000214EE-0000-0000-C000-000000000046}"
#usecom IShellLink IID_IShellLink CLSID_ShellLink
#comfunc IShellLink_SetArguments 11 str
#comfunc IShellLink_SetIconLocation 17 str, int
#comfunc IShellLink_SetPath 20 str
#define IID_IPersistFile "{0000010b-0000-0000-C000-000000000046}"
#usecom IPersistFile IID_IPersistFile
#comfunc IPersistFile_Save 6 wstr, int
#define IID_IPropertyStore "{886d8eeb-8cf2-4446-8d02-cdba1dbdcf99}"
#define CLSID_PropertyStore "{e4796550-df61-448b-9193-13fc1341b163}"
#usecom IPropertyStore IID_IPropertyStore CLSID_PropertyStore
#comfunc IPropertyStore_SetValue 6 sptr, sptr
#comfunc IPropertyStore_Commit 7

newcom ShellLink, IShellLink

IShellLink_SetPath ShellLink, dirinfo(1)+"\\hsptmp.exe"	
IShellLink_SetArguments ShellLink, ""
IShellLink_SetIconLocation ShellLink, dirinfo(1)+"\\hsptmp.exe", 0

querycom propStore, ShellLink, IPropertyStore

// Unicodeに変換
sdim wstring
cnvstow wstring, "net.hinekure.test.hsp3"
// 配列なので(今回は1つしかないけど)
wstrings = varptr(wstring)

// PROPVARIANT 構造体
dim ppropvar, 4
// Unicode文字列→PROPVARIANT に変換
InitPropVariantFromStringVector varptr(wstrings), 1, varptr(ppropvar)
mes strf("0x%08x, %d", stat, stat)

PKEY_AppUserModel_ID = 0x9F4C2855, 0x4B399F79, 0xD4E1D0A8, 0xF3D5E12D, 5
IPropertyStore_SetValue propStore, varptr(PKEY_AppUserModel_ID), varptr(ppropvar)
mes strf("0x%08x, %d", stat, stat)
IPropertyStore_Commit propStore
mes strf("0x%08x, %d", stat, stat)

IPersistFile_Save ShellLink, "test.lnk", 1