|
I hope this helps...
CString CDlgReg::GetDriveID()
{
char dbits[100],drive[100];
int i;
i=0;
DWORD d=GetLogicalDriveStrings(100, dbits);
strncpy(drive,dbits+i,4);
for (int nDrives = 0; nDrives < 26; nDrives ++)
{
if(GetDriveType(drive)==DRIVE_FIXED)
break;
i+=4;
strncpy(drive,dbits+i,4);
}
char vol[40];
DWORD mf;
DWORD sf,sno;
GetVolumeInformation(drive,vol,sizeof(vol),&sno,&mf,&sf,NULL,NULL);
m_dDriveID=sno;
CString s;
s.Format("%08X",sno);
return s;
}
|
|
|
|
|
GetVolumeInformation returns logical serial number of a volume, not the serial number of hard drive!;P
ARSALAN MALIK
|
|
|
|
|
Thank you, but this retrieves a so called "serial number" assigned to a logical drive when the drive is formatted.
I am interested in the manufacturer's serial number, the REAL serial number of the drive.
Thanks for replying.
|
|
|
|
|
Win32_DiskDrive is a WMI class which can give u this serial no.
Imagine that you are creating a fabric of human destiny with the object of making men happy in the end, giving them peace and rest at last, but that it was essential and inevitable to torture to death only one tiny creature..and to found that edifice on its unavenged tears, would you consent to be the architect on those conditions? Tell me, and tell me the truth!
-Fyodor Dostoevsky, The Brothers Karamazov
|
|
|
|
|
Hi,
I am converting one application from IPv4 to IPv6. The application is usign
MFC socket class CSocket and CAsyncSocket.
::: My Query :::
1. When I compile my application for IPv6 by defining IPV6STRICT. I am
getting errors in Afxsock.h. I believe CSocket and CAsyncSocket (for MFC 4.2)
doesn't support IPv6. Please reply if this is true.
2. How can I make sure that CSocket and CAsyncSocket supports IPv6. ?
or
3. How can I include IPv6 support for CSocket and CAsyncSocket classes. ?
::: Some Backgroud :::
1. I am using VS 6.0 with service pack 6.
2. I am using XPSP-2 SDK.
Please reply if any one has faced same problem.
Thanks for your reply.
Regards
Alpha
|
|
|
|
|
Code your own socket class.
Don't try it, just do it!
|
|
|
|
|
I strongly believe in same. Maybe i have to code my own CSocket to support IPv6 .
Thanx
Alpha
|
|
|
|
|
How do I have to connect to COM object from a simple console application. The problem I have is like that:
Client.obj : error LNK2001: unresolved external symbol _CLSID_IOConverter
Client.obj : error LNK2001: unresolved external symbol _IID_IIOConverter
Debug/Client.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
Client.exe - 3 error(s), 0 warning(s)
My code:
DEFINE_GUID(CLSID_IOConverter,...)
DEFINE_GUID(CLSID_IOConverter,...)
int main(int argc, char* argv[])
{
CComPtr<iioconverter> converter = NULL;
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
CoCreateInstance(CLSID_IOConverter,NULL, CLSCTX_INPROC_SERVER,IID_IIOConverter,(void**)&converter);
CoUninitialize();
return 0;
}
What do I have to change?
|
|
|
|
|
There's only one error in the actual code. The CComPtr is a template class, and should be declared accordingly. Either you have forgotten the < and > signs or the forum is not displaying them. Anyway they should be there.
The linker errors are generated because the GUIDs you define do not explicitly state the precise GUID numbers you wish to use. I couldn't find the IIOConverter interface definition from anywhere, so more than likely you have forgotten to link with the static library that defines these interfaces, or have forgotten to include a necessary header file. Check your settings.
There doesn't seem to be other errors. If you need more help, you need to paste the entire DEFINE_GUID macros, and not just "..." as they might cause the errors as well. Also, you have not defined the IID_IIOConverter properly, thus the error. You can use __uuidof( IIOConverter ) if you don't know the interface's GUID, but know the interface name.
Also remember that in order to use the CComPtr class, include atlcomcli.h. To use CoInitializeEx, include objbase.h and link with ole32.lib. Remember that these are Platform SDK features, so you need to define the correct versioning macros as well. For more information, see MSDN with "Platform SDK, Using the Platform SDK" index word.
Hope this helps
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi Dear,
I've added MS Chart Control ActiveX by Project=>Add to Project=>Companent & selected register control. That added lot of classes in my project.
Now I want to remove that ActiveX & their classes. How to do this?
Thanks
---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
|
|
|
|
|
Remove the Classes. The Classes are not the control itselfe. They just interface it.
Hardy
|
|
|
|
|
Hi ,
I want to fancy window style with 3D Title bar and.
Guide me.Thank You.
|
|
|
|
|
|
Hi everyone,
Can anyone give me the sample source code how to perform serial communication in VC++?
Please guide me.
With thanks
War War....
phoophoo2004@indiatimes.com
|
|
|
|
|
|
|
Hi,
I'm trying to convert a tm structure (which has already been adjusted to GMT) into a time_t.
The mktime function adjusts for timezone but this is not what I want.
libc includes _mkgmtime (doesn't seem to be documented) but msvcrt does not.
Is there any easy way I can do this without copying the _make_time_t function from mktime.c (the common code for mktime and _mkgmtime) with all it's dependent bits.
Thanks.
|
|
|
|
|
I want to emmbed Flash (*.swf) into Visual C++ project but i don't know. Can you help me, please????????
Thank you very much!!!!
my email: quocbaonguyen@gmail.com
|
|
|
|
|
Hello,
If you are using VC6,
at the menu bar:
[Project]
[Add To Project]
[Components And Controls]
An explorer-like window(Components and Controls Gallery) will appear.
At the folder
"Registered ActiveX Controls"
select the
"Shockwave Flash Object" file and then press [Insert]
When you go back to Resource View, the activeX control for Macromedia Flash is already added to the controls tool bar.
goodluck.
|
|
|
|
|
I use code which downloaded at "http://codeguru.com/Cpp/I-N/network/networkinformation/article.php/c2441/" for my project but i can't enumerate my network.
Because my entire network (in Explorer) can't view my workgroups. I can find any computer and access any computer by "\\computer's name" in my network.
I want to enumerate my network. Can you help me? Help me, please!!!!!
Thank you very much!!!!!
my email: quocbaonguyen@gmail.com
|
|
|
|
|
Hey Guys,
I am new to the whole world of C++ and have been studying a few samples / examples off the web of C++ coding etc. I made a short code / program called "The Namorizer" which is a console program that asks for your first name, then your last and finally adds them together and displays the result i.e your full name.
What I am trying to accomplish here is to do the same thing but with a windows form. I have designed the form in VS2k3 and now would like to add the code to the various textboxes etc for the events. I am kind of lost at this point of what to do and would like someone with patience and skills in communication just to spend a few minutes explaining where I would put this and also perhaps providing me with links to good sites and tutorials to learn from.
Thank you in advance for any help you can give.
neo.
|
|
|
|
|
Basically, you need to decide how it will all work. The most simple way is to set up two text boxes, call them tbFirst and tbLast ( for example ), then add a button. Double clicking on the button in the designer will create a handler in your code for the button being clicked, although giving it a meaningful name first will mean the function will have a useful name. First create a label, and call it lblName ( for the sake of the example ). Now, from memory, what you need to do in your handler is something like
lblName.SetWindowText(tbFirst.GetWindowText()+ " " + tbLast.GetWindowText());
I'm a long way from C++ land though, let alone MFC, so I could have some of the details wrong.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Good answer to most is read:
SAMS - Teach Yourself Visual C++ In 21 Days.pdf
|
|
|
|
|
I have a Byte buffer that I'm receving data into from an CAsyncSocket call (Receive)
BOOL bRetCode;<br />
DWORD dwBytesToRead;<br />
<br />
bRetCode = m_sConnectSocket.IOCtl(FIONREAD, &dwBytesToRead);<br />
<br />
BYTE* RecvBuffer = new BYTE[(int)dwBytesToRead];<br />
<br />
m_sConnectSocket.Receive(RecvBuffer, sizeof(RecvBuffer));<br />
<br />
onParseData(RecvBuffer, sizeof(RecvBuffer));<br />
In my onParseData function I'm trying to parse out the data. I know that certain parts of the data stream are a fixed length. So I created a structure.
struct ParseData{<br />
BYTE STAP[4]; <br />
BYTE BlockLen;<br />
BYTE HDRLen;<br />
BYTE FunctionCode;<br />
BYTE ValField;<br />
BYTE DataLen;<br />
BYTE MsgStatus;<br />
BYTE Dest;<br />
char* DataPacket;<br />
BYTE STOP[4];<br />
};<br />
ParseData myStuff;<br />
memcpy(&myStuff, dataBuffer, sizeof(myStuff));<br />
My problem is that I feel that this is not going to work and that I get an exception error because of the char* DataPacket; .
And I'd love to make my sturcture like this:
struct ParseData{<br />
BYTE STAP[4]; <br />
int BlockLen;<br />
int HDRLen;<br />
int FunctionCode;<br />
int ValField;<br />
int DataLen;<br />
int MsgStatus;<br />
int Dest;<br />
char* DataPacket;<br />
BYTE STOP[4];<br />
};<br />
I just want some direction in to where I need to go to find out:
1. How do I move this BYTE array into this structure?
2. Is there a simple way to just pull out certain parts of the data stream and plop it into the structure? example...move the first 4 bytes to the STAP the second 4 to the BlockLen...etc.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
The problem is that a char * is the address where an array of char's can be found. In unpacking your data, you need to work out how long the string is, call new on the char * in the struct, and then assign the value. If I were you, I'd put a std::string in the struct instead, that way you don't need to clean up memory.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|