|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Member
Iscritto dal: Nov 2002
Messaggi: 250
|
[Visual C++] gestione processi
ciao gentilissimi amici.
sapete se esiste qualche API di windows che permetta di monitorare un determinato processo in esecuzione, controllandone per esempio l'occupazione in ram? e altre informazioni riguardo allo stato della macchina, quali: utilizzo cpu, banda rete lan, ecc. vi ringrazio ![]() Ultima modifica di Zhurlo : 07-10-2008 alle 14:47. Motivo: modifica titolo |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Mar 2007
Messaggi: 1792
|
La Process API (PSAPI) ed i Performance Counters potrebbero tornarti utili. Per tutto il resto (e non solo) c'è WMI...
![]() |
![]() |
![]() |
![]() |
#3 |
Member
Iscritto dal: Nov 2002
Messaggi: 250
|
bellooo che ficataaaa!!
![]() ma serve il .NET per sviluppare con queste moltitudini di API? riesci a darmi qualche dritta in più? per adesso ho solo il Visual C++ 2005 express edition... ![]() |
![]() |
![]() |
![]() |
#4 | |
Bannato
Iscritto dal: Mar 2008
Città: Villabate(PA)
Messaggi: 2515
|
Quote:
no, non serve il .net per PSAPI. Puoi vedere qui: http://msdn.microsoft.com/en-us/libr...84(VS.85).aspx http://msdn.microsoft.com/en-us/libr...50(VS.85).aspx In .net ci sarà sicuramente qualcosa che ti facilita enormemente il compito. Ma non ti consiglio, in questo caso di usare il C++ con le estensioni per il CLR: molto meglio usare C#. La express edition puoi scaricarla gratuitamente. Ultima modifica di Vincenzo1968 : 07-10-2008 alle 16:55. |
|
![]() |
![]() |
![]() |
#5 | |
Senior Member
Iscritto dal: Mar 2007
Messaggi: 1792
|
Un metodo migliore rispetto all'allocazione statica del buffer è mostrato in Enumerating Windows Processes:
Quote:
|
|
![]() |
![]() |
![]() |
#6 |
Member
Iscritto dal: Nov 2002
Messaggi: 250
|
ciao ragazzi, ho provato qualche programmino di scripting in vbscript e mi sto divertendo un sacco
![]() tipo questo: Codice:
' Check command line parameters Select Case WScript.Arguments.Count Case 0 ' Default if none specified is local computer (".") Set objWMIService = GetObject( "winmgmts://./root/cimv2" ) Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem", , 48 ) For Each objItem in colItems strComputer = objItem.Name Next Case 1 ' Command line parameter can either be a computer ' name or "/?" to request online help strComputer = UCase( Wscript.Arguments(0) ) if InStr( strComputer, "?" ) > 0 Then Syntax Case Else ' Maximum is 1 command line parameter Syntax End Select ' Define constants Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 ' Header line for screen output strMsg = vbCrLf & "CPU type for " & strComputer & ":" & vbCrLf & vbCrLf ' Enable error handling On Error Resume Next ' Connect to specified computer Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" ) ' Display error number and description if applicable If Err Then ShowError ' Query processor properties Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly) ' Display error number and description if applicable If Err Then ShowError ' Prepare display of results For Each objItem In colItems strMsg = strMsg _ & "Device ID : " & objItem.DeviceID & vbCrLf _ & "CPU Type : " & Strip( objItem.Name ) & vbCrLf & vbCrLf Next ' Display results WScript.Echo strMsg 'Done WScript.Quit(0) Sub ShowError() strMsg = vbCrLf & "Error # " & Err.Number & vbCrLf & _ Err.Description & vbCrLf & vbCrLf Syntax End Sub Sub Syntax() strMsg = strMsg & vbCrLf _ & "CPUType.vbs, Version 1.00" & vbCrLf _ & "Display CPU type for any computer " _ & "on the network" & vbCrLf & vbCrLf _ & "Usage: CSCRIPT //NOLOGO CPUTYPE.VBS " _ & "[ computer_name ]" & vbCrLf & vbCrLf _ & "Where: " & Chr(34) & "computer_name" & Chr(34) _ & " is the optional name of a remote" & vbCrLf _ & " computer (default is local computer " _ & "name)" & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" & vbCrLf _ & "http://www.robvanderwoude.com" & vbCrLf & vbCrLf _ & "Created with Microsoft's Scriptomatic 2.0 tool" & vbCrLf _ & "http://www.microsoft.com/downloads/details.aspx?" & vbCrLf _ & " FamilyID=09dfc342-648b-4119-b7eb-783b0f7d1178&DisplayLang=en" & vbCrLf WScript.Echo strMsg WScript.Quit(1) End Sub Private Function Strip( strInput ) Do While Left( strInput, 1 ) = " " strInput = Mid( strInput, 2 ) Loop Strip = strInput End Function che stampa le informazioni legate alla CPU. Ho qui per voi una domanda: è possibile inserire questo script all'interno di una pagina web e stampare il risultato all'interno della pagina? senza finestre di alert quindi. Ho provato a inserire il codice all'interno dei TAG <script language="VBScript"></script>ma non stampa nulla (uso internet explorer 6.0) più tardi proverò a scrivere un programmino in Visual C++, vedremo che succederà........ ![]() ![]() ![]() Ultima modifica di Zhurlo : 08-10-2008 alle 14:16. |
![]() |
![]() |
![]() |
#7 |
Member
Iscritto dal: Nov 2002
Messaggi: 250
|
ciau raghi, ho provato a sosituire WScript.Echo con document.write, ma anche in questo caso non da segni di vita
![]() aiutino?? ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
![]() |
#8 |
Member
Iscritto dal: Nov 2002
Messaggi: 250
|
altro problema: ho provato un semplice programmino in Visual C++ 2005 (Enterprise edition) ma quando faccio Build non mi trova la libreria <comdef.h> e neanche <Wbemidl.h>
come faccio? ![]() |
![]() |
![]() |
![]() |
#9 |
Member
Iscritto dal: Nov 2002
Messaggi: 250
|
|
![]() |
![]() |
![]() |
#10 |
Member
Iscritto dal: Nov 2002
Messaggi: 250
|
Ho risolto installando l'SDK
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 17:34.