CPP: How to wait on a job object?

This is the sample code in CPP to show how to wait on a job object. In the documentation:   The state of a job object is set to signaled when all of its processes are terminated because the specified end-of-job time limit has been exceeded. Use WaitForSingleObject or WaitForSingleObjectEx to monitor the job object…


How to query network adapter for IPv6 protocol?

Assuming you need it in script, PowerShell: # computername $MachineName = ‘localhost’   # open HKLM reg on $MachineName $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘LocalMachine’, $MachineName)   # open subKey SYSTEMCurrentControlSetservicesTCPIP6Linkage $regKey = $reg.OpenSubKey(“SYSTEM\CurrentControlSet\services\TCPIP6\Linkage”)   # get the values from the name ‘Bind’ # e.g. Device{A2B312D5-A133-4779-B21B-5B3ED82B6DCF} $bind = $regKey.GetValue(“bind”)   # get adapters that are IP enabled :…


C# - How to load DLL in separate domain and use its methods?

Sometimes you may have a need to load a DLL in a separate domain to call its method at run-time. You can create a proxy class by referencing the following code snippet: public class Loader : MarshalByRefObject { object CallInternal(string dll, string typename, string method, object[] parameters) { Assembly a = Assembly.LoadFile(dll); object o = a.CreateInstance(typename);…


How to determine if current user is a domain or local user?

Assuming you need it in script, PowerShell:   (gwmiWin32_LogonSession).GetRelated(“Win32_UserAccount”)   If you expect more than one logon session, then   (gwmi Win32_Process -filter “Handle = $Pid”).GetRelated(“Win32_LogonSession”) |% {$_.GetRelated(“Win32_UserAccount”)}   will give you Win32_UserAccount for the account used to run current powershell instance.