|
The project in not running in VS2008, what changes i should do to run
|
|
|
|
|
just fix the code. most likely it's the header's path, so check the project settings.
|
|
|
|
|
i want to get hd Info of other computer through network..any solution or suggesstion????
|
|
|
|
|
Hi dmihailescu,
If there are more than 1 HDD installed in a computer, lets say that there are 2 HDDs.
1st HDD is partitioned into 3 partitions namely C:, D;, and E:
2nd HDD is partition into 2 partitions namely F: and G:
How to know one partition belongs to which HDD?
I mean how to know F: belongs to 2nd HDD, and C: belongs to 1st HDD?
Thanks,
Best regards,
Leo
|
|
|
|
|
// Mac Address.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdafx.h"
#include <windows.h>
#include <conio.h>
#include <string>
#include<iostream>
#include <fstream>
#include <lm.h>
#include <assert.h>
#include <winsock.h>
#define _WIN32_DCOM
#include <iostream>
#include <comdef.h>
#include <wbemidl.h>
#include <comutil.h>
#pragma comment(lib, "Netapi32.lib")
#pragma comment(lib, "wsock32.lib")
# pragma comment(lib, "wbemuuid.lib")
using namespace std;
void filewrite(string a,int e)
{
ofstream fout;
if(e==1)
fout.open("System Configuration.txt");
else
{
fout.open("System Configuration.txt", ios::app);
fout<<a;
fout<<endl;
="" }
=""
="" fout.close();
=""
}=""
void="" getmac()
{
="" unsigned="" char="" macdata[8];
="" wksta_transport_info_0="" *pwkti;
="" dword="" dwentriesread;
="" dwtotalentries;
="" byte="" *pbbuffer;
="" net_api_status="" dwstatus="NetWkstaTransportEnum(
" null,="" [in]="" server="" name
="" 0,="" data="" structure="" to="" return
="" &pbbuffer,="" [out]="" pointer="" buffer
="" max_preferred_length,="" maximum="" length
="" &dwentriesread,="" counter="" of="" elements="" actually="" enumerated
="" &dwtotalentries,="" total="" number="" that="" could="" be="" null);="" [in="" out]="" resume="" handle
="" assert(dwstatus="=" nerr_success);
="" pwkti="(WKSTA_TRANSPORT_INFO_0" *)pbbuffer;="" type="" cast="" the="" buffer
="" for(dword="" i="1;" i<="" dwentriesread;="" i++)="" first="" address="" is="" 00000000,="" skip="" it
="" {="" dd[33];="" enumerate="" macs="" and="" print
="" swscanf((wchar_t="" *)pwkti[i].wkti0_transport_address,="" l"%2hx%2hx%2hx%2hx%2hx%2hx",="" &macdata[0],="" &macdata[1],="" &macdata[2],="" &macdata[3],="" &macdata[4],="" &macdata[5]);
="" printmacaddress(macdata);
="" sprintf(dd,"="" %02x-%02x-%02x-%02x-%02x-%02x\n",macdata[0],="" macdata[1],="" macdata[2],="" macdata[3],="" macdata[4],="" macdata[5]);
="" string="" u="MAC Address :" ;
="" u+="dd;
" filewrite(u,0);
="" release="" pbbuffer="" allocated="" by="" above="" function
="" nerr_success);
}
void="" getip()
{
="" word="" wversionrequested;
="" wsadata="" wsadata;
="" name[255];
="" phostent="" hostinfo;
="" wversionrequested="MAKEWORD(" 1,="" 1="" );
="" *ip;
="" if="" (="" wsastartup(="" wversionrequested,="" &wsadata="" )="=" 0="" )
="" if(="" gethostname="" name,="" sizeof(name))="=" 0)
="" {
="" printf("host="" name:="" %s\n",="" name);
="" name1="Computer Name: " name1+="name;
" filewrite(name1,0);
="" if((hostinfo="gethostbyname(name))" !="NULL)
" int="" ncount="0;
" while(hostinfo-="">h_addr_list[nCount])
{
ip = inet_ntoa (*(struct in_addr *)hostinfo->h_addr_list[nCount]);
++nCount;
//printf("IP #%d: %s\n", ++nCount, ip);
string s="IP Adress : ";
s+=ip;
filewrite(s,0);
}
}
}
}
void getsn_no()
{
CoInitializeEx(0, COINIT_MULTITHREADED);
CoInitializeSecurity(
NULL,
-1, // COM authentication
NULL, // Authentication services
NULL, // Reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication
RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation
NULL, // Authentication info
EOAC_NONE, // Additional capabilities
NULL // Reserved
);
IWbemLocator *pLoc = NULL;
CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *) &pLoc);
IWbemServices *pSvc = NULL;
pLoc->ConnectServer(
_bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace
NULL, // User name. NULL = current user
NULL, // User password. NULL = current
0, // Locale. NULL indicates current
NULL, // Security flags.
0, // Authority (e.g. Kerberos)
0, // Context object
&pSvc // pointer to IWbemServices proxy
);
IEnumWbemClassObject* pEnumerator = NULL;
ULONG uReturn;
int i=1,x=0;
LPCWSTR lp3;
_bstr_t win32;
string data;
while(i<=7)
{
switch(i)
{
case 1:
filewrite("MOTHER BOARD",0);
win32="SELECT * FROM Win32_BaseBoard";
lp3=L"SerialNumber";
data="SerialNumber :";
break;
case 2:
win32="SELECT * FROM Win32_BaseBoard";
lp3=L"Product";
data="Product ID :";
break;
case 3:
win32="SELECT * FROM Win32_Processor";
lp3=L"ProcessorId";
data="Processor Id :";
x=1;
cout<<"Configuring Software....."<<endl<<endl;
break;
="" case="" 4:
="" filewrite("",0);
="" filewrite("hard-disk="" &="" flas="" drive",0);
="" win32="SELECT * FROM Win32_DiskDrive" ;
="" lp3="L"Model";
" data="Model NO : " 5:
="" 6:
="" filewrite("local="" disk's="" serial="" no.",0);
="" x="3;
" 7:
="" filewrite("os="" name="" |path|="" |partition|",0);
="" }
="" i++;
="" psvc-="">ExecQuery(
bstr_t("WQL"),
bstr_t(win32),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
IWbemClassObject *pclsObj;
uReturn = 0;
//filewrite("HD&FLASH DRIVE's ",0);
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,&pclsObj, &uReturn);
if(0 == uReturn)
{
break;
}
VARIANT vtProp;
// Get the value of the Name property
pclsObj->Get(lp3, 0, &vtProp, 0, 0);
data+=(const char*)_bstr_t(vtProp.bstrVal);
if(x==3)
{
lp3=L"VolumeSerialNumber";
string n;
n=data;
n+=" ";
pclsObj->Get(lp3, 0, &vtProp, 0, 0);
n+=(const char*)_bstr_t(vtProp.bstrVal);
data=n;
lp3=L"Name";
}
filewrite(data,0);
VariantClear(&vtProp);
pclsObj->Release();
data.clear();
if(x==1)
{
x=0;
break;
}
}
}
pSvc->Release();
pLoc->Release();
pEnumerator->Release();
CoUninitialize();
}
int _tmain(int argc, _TCHAR* argv[])
{
filewrite("",1);
cout<<"Configuring Hardware....."<
|
|
|
|
|
|
|
Nice Code, but I try to figure out how to identify the device driver used for a Physical Disk. Could be PCIIDE, MSAHCI, IASTOR, AMD_AHCI or other, depending on the controller and the mode it is using (IDE, AHCI oder RAID). Does anyone have a solution?
|
|
|
|
|
This project is wrapper under DiskID32 library.
Link to original library WinSim Inc
Also code in this article wrap old version of this library.
|
|
|
|
|
I thought you had the link for the original code at in the article[^].
The code was current years ago, if you found some new C++ code you are free to update it.
|
|
|
|
|
this do not work in C# 4.
and have error in win7
|
|
|
|
|
zomorrod.company wrote:
this do not work in C# 4. and have error in
win7
you need to rebuid the C++ code with VS2010 if using C# 4.
The UAC might not allow it in windows 7 unless you disable it.
|
|
|
|
|
It is possible to enumerate the drive letters, or to make a match between a drive letter and a HDD in some way?
|
|
|
|
|
Dear sir,
In Windows 7 ultimate , "Release" can't display drive info until i run it with "Run as Administrator" .
I tried this dll into my c# application but can't get information (it display count = 0 on debugging ) i think it redquires admin. rights to run dll ... how to solve it
|
|
|
|
|
|
Very nice............It has get me out of My very hard problem.......
|
|
|
|
|
Sorry to bother about those questions but I don't know c++ and I'm gonna explain my situation.
I created a web app and I want to run it on a cd with asteclick wbea witch uses chrome embedded framework. I have visual c++ 2008 express edition and I downloaded wbea's source code. I was able to compile it fine but I saw in the code the ability to control or access the app with javascript. My idea was to find the cd or dvd serial in c++ using your code and assign it to a string to access it via javascript on my web app.
So basically I was wondering how do I use this in the c++ project to assign the cd or dvd serial to a string.
Sorry for my poor english, my primary language is french.
Thank's
|
|
|
|
|
|
I've never tested it with win7.
|
|
|
|
|
I have a problem to get a Serial number of HDD wich is connected through RAID controller.
I tried to also a DiskID32 it does not give a Serial NUmber too....
|
|
|
|
|
I have run your Demo project binaries on my win7 and dll just work well. therefore, i included it in my project and try to run on target machine which have win Xp with .NET2.0 installed. it's not work neither on my Project as well as yours. below are the Exception of UIHost.exe.
whats going wrong?
************** Exception Text **************
System.IO.FileLoadException: Could not load file or assembly 'DriveInfoEx, Version=1.1.3054.15437, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)
File name: 'DriveInfoEx, Version=1.1.3054.15437, Culture=neutral, PublicKeyToken=null' ---> System.Runtime.InteropServices.COMException (0x800736B1): This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)
at UIClient.MainForm.MainForm_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
UIClient
Assembly Version: 1.1.0.0
Win32 Version: 1.1.0.0
CodeBase: file:///D:/released/UIClient.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
|
|
|
|
|
I'm also having the same problem..Works fine with machines that has C++ runtime library is installed..but what happens if not installed ?? Does any one has a solution for this..pls..
|
|
|
|
|
|
I have tried this software and it works on win 64 if you wrap it inside a .net dll targeting x86 cpu.
|
|
|
|
|
Great.
|
|
|
|
|