Exemplo n.º 1
0
        internal static string WSManGetSessionOptionAsString(
            IntPtr wsManAPIHandle,
            WSManNativeApi.WSManSessionOption option)
        {
            string str = "";
            int    optionLengthUsed = 0;

            if (122 != WSManNativeApi.WSManGetSessionOptionAsString(wsManAPIHandle, option, 0, (byte[])null, out optionLengthUsed))
            {
                return(str);
            }
            byte[] numArray = new byte[optionLengthUsed * 2];
            if (WSManNativeApi.WSManGetSessionOptionAsString(wsManAPIHandle, option, optionLengthUsed * 2, numArray, out int _) != 0)
            {
                return(str);
            }
            try
            {
                str = Encoding.Unicode.GetString(numArray);
            }
            catch (ArgumentNullException ex)
            {
            }
            catch (DecoderFallbackException ex)
            {
            }
            return(str);
        }
        internal void SetWSManSessionOption(WSManNativeApi.WSManSessionOption option, int dwordData)
        {
            int errorCode = WSManNativeApi.WSManSetSessionOption(this.wsManSessionHandle, option, new WSManNativeApi.WSManDataDWord(dwordData));

            if (errorCode != 0)
            {
                throw new PSInvalidOperationException(WSManNativeApi.WSManGetErrorMessage(WSManClientSessionTransportManager.wsManApiStaticData.WSManAPIHandle, errorCode));
            }
        }
Exemplo n.º 3
0
 internal static int WSManSetSessionOption(
     IntPtr wsManSessionHandle,
     WSManNativeApi.WSManSessionOption option,
     WSManNativeApi.WSManDataDWord data)
 {
     WSManNativeApi.MarshalledObject marshalledObject = data.Marshal();
     using (marshalledObject)
         return(WSManNativeApi.WSManSetSessionOption(wsManSessionHandle, option, marshalledObject.DataPtr));
 }
 internal void SetWSManSessionOption(WSManNativeApi.WSManSessionOption option, string stringData)
 {
     using (WSManNativeApi.WSManData wsManData = new WSManNativeApi.WSManData(stringData))
     {
         int errorCode = WSManNativeApi.WSManSetSessionOption(this.wsManSessionHandle, option, (IntPtr)wsManData);
         if (errorCode != 0)
         {
             throw new PSInvalidOperationException(WSManNativeApi.WSManGetErrorMessage(WSManClientSessionTransportManager.wsManApiStaticData.WSManAPIHandle, errorCode));
         }
     }
 }
Exemplo n.º 5
0
 private static extern int WSManGetSessionOptionAsString(
     IntPtr wsManSessionHandle,
     WSManNativeApi.WSManSessionOption option,
     int optionLength,
     byte[] optionAsString,
     out int optionLengthUsed);
Exemplo n.º 6
0
 internal static extern void WSManGetSessionOptionAsDword(
     IntPtr wsManSessionHandle,
     WSManNativeApi.WSManSessionOption option,
     out int value);
Exemplo n.º 7
0
 internal static extern int WSManSetSessionOption(
     IntPtr wsManSessionHandle,
     WSManNativeApi.WSManSessionOption option,
     IntPtr data);