#module
#uselib "Ntdll"
#func NtQueryObject "NtQueryObject" int, int, int, int, int
#uselib "kernel32"
#cfunc GetCurrentProcess "GetCurrentProcess"
#define ObjectBasicInformation 0
#defcfunc GetProcessRefarencecount
ret = 0
dim PUBLIC_OBJECT_BASIC_INFORMATION, 14
NtQueryObject GetCurrentProcess(), ObjectBasicInformation, varptr(PUBLIC_OBJECT_BASIC_INFORMATION), 14*4, varptr(ret)
return PUBLIC_OBJECT_BASIC_INFORMATION.2
#global
mes GetProcessRefarencecount()
定期的に GetProcessRefarencecount() を実行して値が変化していたら、
ダイアログを出すなり終了するなりすればよいかと。