Ejemplo n.º 1
0
 public static extern uint PowerReadACValue(
     //This parameter is reserved for future use and must be set to NULL.
     [In][Optional] IntPtr RootPowerKey,
     //The identifier of the power scheme
     [In][Optional] PowerPlanHandle SchemeGuid,
     //The subgroup of power settings.This parameter can be one of the following values defined in WinNT.h.Use NO_SUBGROUP_GUID to retrieve the setting for the default power scheme.
     [In][Optional] ref Guid SubGroupOfPowerSettingsGuid,
     //The identifier of the power setting.
     [In][Optional] ref Guid PowerSettingGuid,
     //A pointer to a variable that receives the type of data for the value. The possible values are listed in Registry Value Types.This parameter can be NULL and the type of data is not returned.
     [Out][Optional] out RegistryTypes Type,
     //A pointer to a buffer that receives the data value. If this parameter is NULL, the BufferSize parameter receives the required buffer size.
     [Out][Optional] IntPtr Buffer,
     //A pointer to a variable that contains the size of the buffer pointed to by the Buffer parameter.
     //If the Buffer parameter is NULL, the function returns ERROR_SUCCESS and the variable receives the required buffer size.
     //If the specified buffer size is not large enough to hold the requested data, the function returns ERROR_MORE_DATA and the variable receives the required buffer size.
     [In][Out][Optional] ref uint BufferSize);
Ejemplo n.º 2
0
 public static WxUser CreateWxUser(this WeChatUserInfo userInfo, RegistryTypes type, string appid)
 {
     return(new WxUser()
     {
         AppId = appid,
         AvatarUrl = userInfo.AvatarUrl,
         City = userInfo.City,
         Country = userInfo.Country,
         CreatedTime = DateTime.Now.ToUnixStampDateTime(),
         LastActivityTime = DateTime.Now.ToUnixStampDateTime(),
         Mobile = string.Empty,
         NickName = userInfo.NickName,
         OpenId = userInfo.OpenId,
         Province = userInfo.Province,
         RegistryType = RegistryTypes.Miniprogram,
         UnionId = userInfo.UnionId
     });
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Retrieve System DSN
        /// </summary>
        /// <param name="taskID">Task ID</param>
        /// <param name="wmiRegistry">WMI Registry</param>
        /// <param name="queryResults">Result Buffer</param>
        /// <returns></returns>
        private static ResultCodes GetSystemDSN(string taskID,
                                                ManagementClass wmiRegistry,
                                                IDictionary <string, IDictionary <string, string> > odbcDrivers,
                                                IDictionary <string, IDictionary <string, string> > systemDSNs)
        {
            string dsnRegPath = @"SOFTWARE\ODBC\ODBC.INI\";

            string[]        dsnNames      = null;
            RegistryTypes[] registryTypes = null;
            ResultCodes     resultCode    = Lib.GetRegistryImmediateKeyValues(taskID,
                                                                              wmiRegistry,
                                                                              dsnRegPath + @"ODBC Data Sources",
                                                                              out dsnNames,
                                                                              out registryTypes);

            if (resultCode != ResultCodes.RC_SUCCESS)
            {
                Lib.Logger.TraceEvent(TraceEventType.Error,
                                      0,
                                      @"task ID {0} : Error collecting System DSN from registry HKLM\Software\ODBC.INI\ODBC Data Sources.",
                                      taskID);
                return(ResultCodes.RC_INSUFFICIENT_PRIVILEGE_TO_READ_REGISTRY);
            }
            if (dsnNames != null)
            {
                foreach (string dsnName in dsnNames)
                {
                    string driverType = null;
                    resultCode = Lib.GetRegistryStringValue(taskID,
                                                            wmiRegistry,
                                                            dsnRegPath + @"ODBC Data Sources",
                                                            dsnName,
                                                            out driverType);

                    if (string.IsNullOrEmpty(driverType))
                    {
                        Lib.Logger.TraceEvent(TraceEventType.Error,
                                              0,
                                              @"ID {0} : Error collecting DSN DriverType: {1}",
                                              dsnName);
                        continue;
                    }

                    systemDSNs[dsnName]               = new Dictionary <string, string>();
                    systemDSNs[dsnName]["name"]       = dsnName;
                    systemDSNs[dsnName]["driverType"] = driverType;

                    if (odbcDrivers.ContainsKey(driverType))
                    {
                        if (!odbcDrivers[driverType].ContainsKey(@"systemDSN"))
                        {
                            odbcDrivers[driverType][@"systemDSN"] = dsnName;
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(odbcDrivers[driverType]["systemDSN"]))
                            {
                                odbcDrivers[driverType]["systemDSN"] += ", ";
                            }
                            odbcDrivers[driverType]["systemDSN"] += dsnName;
                        }
                    }

                    string[]        subKeyNames = null;
                    RegistryTypes[] keyDataTypes;
                    resultCode = Lib.GetRegistryImmediateKeyValues(taskID,
                                                                   wmiRegistry,
                                                                   dsnRegPath + dsnName,
                                                                   out subKeyNames,
                                                                   out keyDataTypes);
                    for (int i = 0; i < subKeyNames.Length; i++)
                    {
                        string        keyName = subKeyNames[i];
                        RegistryTypes regType = keyDataTypes[i];

                        if (regType == RegistryTypes.REG_SZ)
                        {
                            string keyValue = string.Empty;
                            Lib.GetRegistryStringValue(taskID,
                                                       wmiRegistry,
                                                       dsnRegPath + dsnName,
                                                       keyName,
                                                       out keyValue);
                            systemDSNs[dsnName][keyName] = keyValue;
                        }
                    }
                }
            }
            return(ResultCodes.RC_SUCCESS);
        }