|
|
anwar1026 wrote: I want to know how to find the HDD Serial Number from using C++ or C or any assembly code.
Check GetVolumeInformation() API where you get the information of the volume serial number in lpVolumeSerialNumber parameter.
Here you get more information[^]
Knock out 't' from can't,
You can if you think you can
-- modified at 8:01 Friday 9th June, 2006
|
|
|
|
|
If you need volume's serial number (for logical disks C:, D:, etc.), you can use GetVolumeInformation function.
If you need serial numbers of your hard disks as physical devices, you can follow the famous Windows Management Instrumentation (WMI) way, which does not look so simple:
#define _WIN32_WINNT 0x0400
#include <objbase.h>
#include <comdef.h>
#include <Wbemidl.h>
# pragma comment(lib, "wbemuuid.lib")
_COM_SMARTPTR_TYPEDEF(IWbemLocator, __uuidof(IWbemLocator));
_COM_SMARTPTR_TYPEDEF(IWbemServices, __uuidof(IWbemServices));
_COM_SMARTPTR_TYPEDEF(IEnumWbemClassObject, __uuidof(IEnumWbemClassObject));
_COM_SMARTPTR_TYPEDEF(IWbemClassObject, __uuidof(IWbemClassObject));
int main()
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
CoInitializeSecurity(
NULL,
-1,
NULL,
NULL,
RPC_C_AUTHN_LEVEL_DEFAULT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE,
NULL);
IWbemLocatorPtr locator;
CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator,
(LPVOID *)&locator
);
IWbemServicesPtr services;
locator->ConnectServer(
_bstr_t(L"ROOT\\CIMV2"),
NULL,
NULL,
0,
NULL,
0,
0,
&services
);
IEnumWbemClassObjectPtr enumerator;
services->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_DiskDrive"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&enumerator);
IWbemClassObjectPtr object = 000;
for( ; ; )
{
ULONG ret;
enumerator->Next(WBEM_INFINITE, 1, &object, &ret);
if( ret == 0) break;
_variant_t variant;
object->Get(L"Caption", 0, &variant, 0, 0);
MessageBox(0, _bstr_t(variant), "The serial number is:", MB_OK);
}
return 0;
}
Hope it helps.
|
|
|
|
|
I cannot find this file
Wbemidl.h
Anwar.
|
|
|
|
|
The "WbemIdl.h" file is located in "Vc*\PlatformSDK\Include\WbemIdl.h" subdirectory of Visual Studio 2003 or 2005. Are you using another compiler? Or may be you have a reduced variant of Visual Studio.
WMI includes more header files, libraries and DLLs. In Windows 98, WMI has to be installed separately.
I think you would have to download WMI from Microsoft site.
|
|
|
|
|
Well... I am using Visual Studio 6.0
And it would not be possible for me to move to Visual Studio .NET 2003 or higher.
Anwar.
|
|
|
|
|
It's part of the Platform SDK.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
|
|
I think you have trouble in your brain?
Sorry....this is wrong forum.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Encrypted query*
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
just for fun!!!
sorry for disturbing u all !!!!
JAYARAJ
|
|
|
|
|
_beginthread(CopyProcessTh, 0, NULL);//error C3867: 'CDlg::CopyProcessTh': function call missing argument list; use '&CDlg::CopyProcessTh' to create a pointer to member
void CDlg::CopyProcessTh(void * p)
{
dlg=new CCopyInterface(this);
if (m_copiedFile.GetLength()!=0)
{
dlg->CopyFileFunct(m_copiedFile,m_leftFolder);
}
}
|
|
|
|
|
NoName II wrote:
_beginthread(CopyProcessTh, 0, NULL);//error C3867: 'CDlg::CopyProcessTh': function call missing argument list; use '&CDlg::CopyProcessTh' to create a pointer to member
1) Made the CopyProcessTh as a static in the class which returns UINT from the function which is recommended to terminate the thread.
OR
2) Seperate out the function from the class with following prototype
UINT CopyProcessTh(LPVOID pparam)
{
return 0;
}
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
I can't made CopyProcessTh as a static cause it should operate with nonstatic members..
as for the 2nd...error C3867: 'CDlg::CopyProcessTh': function call missing argument list; use '&CDlg::CopyProcessTh' to create a pointer to member
|
|
|
|
|
NoName II wrote: I can't made CopyProcessTh as a static cause it should operate with nonstatic members..
You can't pass a non-static member function to _beginthread. The reason is that static and non-static member functions don't have the same prototype. Non-static member functions have an implicit parameter that is passed: the 'this' parameter. Look at the post of WhyteSky for the 'workaround' to this problem.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
There was a recent change to C++ that says you can't write class_name::function_name to get a pointer to the function, you have to write &class_name::function_name
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
See
<br />
void MyThread( LPVOID pv );<br />
...<br />
...<br />
void CTest::RunThread()<br />
{<br />
_beginthread(MyThread,0,NULL);<br />
}<br />
<br />
<br />
void MyThread( LPVOID pv )<br />
{<br />
CTest* m_Answer = (CTest*) pv;<br />
<br />
m_Answer->Modify();<br />
<br />
}<br />
<br />
void CTest::Modify()<br />
{<br />
MessageBox("A");<br />
}
whitesky
|
|
|
|
|
WhiteSky wrote: _beginthread(MyThread,0,NULL);
You meant _beginthread(MyThread,0,this); no ?
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
yes
whitesky
|
|
|
|
|
hi,
i develop one application in VC++-MFC 6.0 ,
this application is responsible for inserting image into the database (oracle)-ODBC.
but when i try to insert a image file , it through a error like
"Data type conversion error."
////////////////////////////////////////////////////////////////////////
CDaoDatabse db;
CDaoRecordset recset(&db);
void CDBODBC::InsertintoDB();
{
CByteArray BlobFile;
BlobFile.RemoveAll(); // I clear the Array
CFile aFile("image.jpg",CFile::modeRead);
BlobFile.SetSize(aFile.GetLength());
aFile.Read(BlobFile.GetData(),aFile.GetLength());
aFile.Close();
COleVariant aVar(BlobFile);
CString Sql = "SELECT * FROM sample3";
db.Open("abc",FALSE,FALSE,"ODBC;UID=abc;PWD=abc;DSN=abc;");
recset.Open(AFX_DAO_USE_DEFAULT_TYPE,Sql,dbAppendOnly);
// bool b=recset.CanUpdate();
recset.AddNew();
recset.SetFieldValue("[num]","6"); //varchar field
recset.SetFieldValue("[photo]",aVar); //BLOB field -image field
recset.Update();
recset.Close();
db.Close();
}
/////////////////////////////////////
it works for Access database ..
but i got error in oracle...
"Data type conversion error."
Try again and again,
At last you will say
I don't know the meaning for impossible.,.
|
|
|
|
|
|
tnx,
but , it is MSACCESS database with the column datatype of "OLE Object"
so using COleVariant class,we convert the image as bytestream to COlevariant..
but i want to do the same thing for oracle ..with the column datatype "BLOB"
here also i create same COleVariant ,but it doesn't acceptable by database field "BLOB".....
"Data type Conversion error"
Try again and again,
At last you will say
I don't know the meaning for impossible.,.
|
|
|
|
|
Hi!
I have here a activeX- component "spectrometer.ocx" with the method "getImage(VARIANT *image)".
If a Application call this method, the activeX have to give back a bitmap (which was included in the ressourses). The bitmap have to convers in a VARIANT.
the Method:
<br />
BOOL CSpectrometerCtrl::getImage(VARIANT* image)<br />
{<br />
AFX_MANAGE_STATE(AfxGetStaticModuleState());<br />
<br />
<br />
CBitmap bmp ;<br />
VARIANT p1;<br />
PICTDESC desc;<br />
HRESULT hres;<br />
<br />
bmp.LoadBitmap(IDB_BITMAP1);<br />
VariantInit(&p1);<br />
<br />
desc.cbSizeofstruct = sizeof(PICTDESC) ;<br />
desc.picType = PICTYPE_BITMAP;<br />
desc.bmp.hbitmap = (HBITMAP)bmp.GetSafeHandle();<br />
IPicture *pd;<br />
<br />
hres = ::OleCreatePictureIndirect(&desc, IID_IPicture, FALSE,(LPVOID*)&pd);<br />
<br />
<br />
if(SUCCEEDED(hres))<br />
{<br />
p1.vt = VT_UNKNOWN;<br />
p1.punkVal = pd;<br />
<br />
*image = p1;<br />
<br />
return TRUE;<br />
}<br />
else<br />
return FALSE;<br />
}
In my Application i call this method and i want that the bitmap is shown on a dialog.
void CSpectrometerTestDlg::OnBnClickedButton1()<br />
{<br />
<br />
VARIANT imageData;<br />
IUnknown* pUnk;<br />
IPicture *pPicture= 0;<br />
long lWidth, lHeight;<br />
int iWidth, iHeight;<br />
<br />
CClientDC pDC(this);<br />
<br />
CDC memdc;<br />
memdc.CreateCompatibleDC(&pDC);<br />
<br />
VariantInit(&imageData);<br />
m_mySpectrometer.getImage(&imageData);<br />
<br />
pUnk = imageData.punkVal;<br />
HRESULT hr = pUnk->QueryInterface(&pPicture);<br />
<br />
if(SUCCEEDED(hr))<br />
{<br />
pPicture->get_Width(&lWidth);<br />
pPicture->get_Height(&lHeight);<br />
<br />
iWidth = (lWidth * GetDeviceCaps(pDC, LOGPIXELSX)) / 2540;<br />
iHeight = (lHeight * GetDeviceCaps(pDC, LOGPIXELSY)) / 2540;<br />
<br />
pPicture->Render(pDC, 0, 0, iWidth, iHeight, 0, lHeight, lWidth, -lHeight, 0);<br />
<br />
<br />
<br />
<br />
}<br />
<br />
}
The variables "iWidth, iHeight" have already the right values. It means that something comes on but the displaying doesn't work.
Is there someone with a Idea? What is wrong?
Thanks
-- modified at 6:50 Friday 9th June, 2006
|
|
|
|
|