Bonjour,
je cherche une methodes pour extraire les informations sur une machine sans utlise les WMI ?
exemple
taille de la RAM ,
% d'utilisation de la RAM
vitesse de Processeur ,
% d'utilisation de Processeur
.....
Bonjour,
je cherche une methodes pour extraire les informations sur une machine sans utlise les WMI ?
exemple
taille de la RAM ,
% d'utilisation de la RAM
vitesse de Processeur ,
% d'utilisation de Processeur
.....
Pourquoi ne pas vouloir utiliser WMI ? C'est plus simple avec
Je ne pense pas que ce soit possible autrement (dans les clefs registre peut-être...).
bonjour ,
j'ai eu des problemes avec les WMI,par fois il me donner une exception lorsque je recupere les infos.
bonjour,
j'ai trouve deux classes pour recuperer les informations sur le Processeur de votre PC ainsi que votre RAM et je les y met dans une seule classe
bon codage
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216 using System; using System.Runtime.InteropServices; /// <summary> /// Fournis des information sur le proceseur /// Type de processeur, Nombre de processeur... /// ... /// </summary> public class CInfoProcesseur { /// <summary> /// Public structure contenant les élément du processeur /// L'accès à ces membres se fait par la classe <B>CInfoMemoire</B> /// </summary> [StructLayout(LayoutKind.Sequential)] public struct ProcesseurStatus { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; public string strProcesseur; } /// <summary> /// Public structure contenant les élément du processeur /// Nécessaires pour la lecture via la DLL /// </summary> [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } /// <summary> /// Public constantes des types de processeurs /// </summary> public const int PROCESSOR_INTEL_386 = 386; public const int PROCESSOR_INTEL_486 = 486; public const int PROCESSOR_INTEL_PENTIUM = 586; public const int PROCESSOR_MIPS_R4000 = 4000; public const int PROCESSOR_ALPHA_21064 = 21064; /// <summary> /// <B>privé</B> contenant les informations lu grace à la methode "Get" /// </summary> public ProcesseurStatus m_StatusProc; /// <summary> /// <B>Constructeur</B> Lecture des infos processeur /// </summary> public CInfoProcesseur() { // Lecture des information sur la memoire m_StatusProc = Get(); } /// <summary> /// <B>privé</B> Accès DLL "kernel32.dll" /// </summary> [DllImport("kernel32.dll")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); /// <summary> /// <B>privé</B> pour la lecture des informations du processeur /// </summary> /// <returns>Retourne un objet de type <B>SystemInfo</B> avec tous les membres initialisés</returns> public static ProcesseurStatus Get() { ProcesseurStatus SysInfo = new ProcesseurStatus(); SYSTEM_INFO pSI = new SYSTEM_INFO(); GetSystemInfo(ref pSI); SysInfo.strProcesseur = pSI.dwProcessorType.ToString ();// "(unknown)"; if (pSI.dwProcessorType == PROCESSOR_INTEL_386) { SysInfo.strProcesseur = "Intel 386"; } if (pSI.dwProcessorType == PROCESSOR_INTEL_486) { SysInfo.strProcesseur = "Intel 486"; } if (pSI.dwProcessorType == PROCESSOR_INTEL_PENTIUM) { SysInfo.strProcesseur = "Intel Pentium"; } if (pSI.dwProcessorType == PROCESSOR_MIPS_R4000) { SysInfo.strProcesseur = "MIPS R4000"; } if (pSI.dwProcessorType == PROCESSOR_ALPHA_21064) { SysInfo.strProcesseur = "DEC Alpha 21064"; } SysInfo.dwActiveProcessorMask = pSI.dwActiveProcessorMask; SysInfo.dwAllocationGranularity = pSI.dwAllocationGranularity; SysInfo.dwNumberOfProcessors = pSI.dwNumberOfProcessors; SysInfo.dwOemId = pSI.dwOemId; SysInfo.dwPageSize = pSI.dwPageSize; SysInfo.dwProcessorLevel = pSI.dwProcessorLevel; SysInfo.dwProcessorRevision = pSI.dwProcessorRevision; SysInfo.dwProcessorType = pSI.dwProcessorType; return SysInfo; } /// <summary> /// <B>Public</B> renvoi le type de processeur /// PROCESSOR_INTEL_386 /// PROCESSOR_INTEL_486 /// PROCESSOR_INTEL_PENTIUM /// PROCESSOR_MIPS_R4000 /// PROCESSOR_ALPHA_21064 /// </summary> /// <returns>Retourne la mémoire physique totale en octets.</returns> public string GetTypeProcesseur() { return m_StatusProc.strProcesseur; } [CLSCompliant(false)] public class NativeMethods { private MEMORYSTATUSEX msex; private uint _MemoryLoad; const int MEMORY_TIGHT_CONST = 80; public bool isMemoryTight() { if (_MemoryLoad > MEMORY_TIGHT_CONST ) return true; else return false; } public uint MemoryLoad { get { return _MemoryLoad; } internal set { _MemoryLoad = value; } } public NativeMethods() { msex = new MEMORYSTATUSEX(); if (GlobalMemoryStatusEx(msex)) { _MemoryLoad = msex.dwMemoryLoad; //etc.. Repeat for other structure members } else // Use a more appropriate Exception Type. 'Exception' should almost never be thrown throw new Exception("Unable to initalize the GlobalMemoryStatusEx API"); } public string GetTotalRAMMemory()//en Mega { return (msex.ullTotalPhys /(1024*1024)).ToString(); } public string GetpercentageUtilisationRAM() { return msex.dwMemoryLoad.ToString(); } [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] private class MEMORYSTATUSEX { public uint dwLength; public uint dwMemoryLoad; public ulong ullTotalPhys; public ulong ullAvailPhys; public ulong ullTotalPageFile; public ulong ullAvailPageFile; public ulong ullTotalVirtual; public ulong ullAvailVirtual; public ulong ullAvailExtendedVirtual; public MEMORYSTATUSEX() { this.dwLength = (uint) Marshal.SizeOf(typeof( MEMORYSTATUSEX )); } } [return: MarshalAs(UnmanagedType.Bool)] [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] static extern bool GlobalMemoryStatusEx( [In, Out] MEMORYSTATUSEX lpBuffer); } }
je n'est pas trouve la signification exacte de chaque info
moi je recherche le pourcentage d'utilisation de pross
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 SysInfo.dwActiveProcessorMask = pSI.dwActiveProcessorMask; SysInfo.dwAllocationGranularity = pSI.dwAllocationGranularity; SysInfo.dwNumberOfProcessors = pSI.dwNumberOfProcessors; SysInfo.dwOemId = pSI.dwOemId; SysInfo.dwPageSize = pSI.dwPageSize; SysInfo.dwProcessorLevel = pSI.dwProcessorLevel; SysInfo.dwProcessorRevision = pSI.dwProcessorRevision; SysInfo.dwProcessorType = pSI.dwProcessorType;
et merci
Salut,
Si tu veux faire simple tu fais une classe en VB.NET et tu utilises le fameux MY
et apres tu fais appel à cette classe en c#
merci playfone ,champomy62,
j'ai trouve une autre solution a mes besoins en utilisant DLL "Kernel32" pour extriare les informations.
merci encore ,
Desole de ne pas partage mon solution ,
et voila la classe qui me permet d' extraire les informations sur la RAM de mon PC en utilisant la mysterieuse DLL de Microsoft(Kernel32.dll) ,
cette DLL vous donnee des informations sur votre hardware (materiels),mais elle y'a une autre USer32.DLL et une troisieme je me rappel pas de son nom.
d'apres ce que j'ai lit dans le internet Kernel32 s'initialise depuis le DOS.
et voila un classe de extraire les infos sur la RAM .
en plus la documentation est rare ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 [CLSCompliant(false)] public class RAMInfo { private MEMORYSTATUSEX msex; private uint _MemoryLoad; const int MEMORY_TIGHT_CONST = 80; public bool isMemoryTight() { if (_MemoryLoad > MEMORY_TIGHT_CONST) return true; else return false; } public uint MemoryLoad { get { return _MemoryLoad; } internal set { _MemoryLoad = value; } } public RAMInfo() { msex = new MEMORYSTATUSEX(); if (GlobalMemoryStatusEx(msex)) { _MemoryLoad = msex.dwMemoryLoad; //etc.. Repeat for other structure members } else // Use a more appropriate Exception Type. 'Exception' should almost never be thrown throw new Exception("Unable to initalize the GlobalMemoryStatusEx API"); } public string GetTotalRAMMemory()//en Mega { return (msex.ullTotalPhys / (1024 * 1024)).ToString(); } public string GetpercentageUtilisationRAM() { return msex.dwMemoryLoad.ToString(); } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] private class MEMORYSTATUSEX { public uint dwLength; public uint dwMemoryLoad; public ulong ullTotalPhys; public ulong ullAvailPhys; public ulong ullTotalPageFile; public ulong ullAvailPageFile; public ulong ullTotalVirtual; public ulong ullAvailVirtual; public ulong ullAvailExtendedVirtual; public MEMORYSTATUSEX() { this.dwLength = (uint)Marshal.SizeOf(typeof(MEMORYSTATUSEX)); } } [return: MarshalAs(UnmanagedType.Bool)] [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] static extern bool GlobalMemoryStatusEx([In, Out] MEMORYSTATUSEX lpBuffer); }
et un grand merci BUNS
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager