|
The short answer is, not easily. You must be the 20th person to post this question or one very close to it in the last couple of months. I have code that will do this but it is part of a commercial application so I can't simply post it
I looks like I'll finally have to give in and write an article describing it as so many people seem to want to know. It means putting other things on hold but watch this space.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Yes...Matthew, you should have to write an article which describes it and definately it will help others.
But at this momonet, can u atleast tell me the Win32 APIs, because I am relally stuck at this point? I used SetupDiGetClassDevs,SetupDiEnumDeviceInfo and SetupDiGetDeviceRegistryProperty APIs. but it gives all the devices. I want only USB devices connected to the system?
Please help me out...!
|
|
|
|
|
OK It sounds like you're most of the way there. You'll probably have something similar to this example this example[^] by now.
You need the GUID for USB devices, GUID_DEVCLASS_USB which lives in devguid.h which is part of the DDK. For maximum compatibility I used the one from \inc\w2k in the 3790.1803 version of the DDK which is available here[^]. You may be able to get this definition from the SDK headers these days, I'm not sure. If all you want is the USB devices of whatever type then that should be enough. If you want devices of a specific type e.g. disks then a call like this might be needed.
<br />
hIntDevInfo = SetupDiGetClassDevs (<br />
(LPGUID)&DiskClassGuid,<br />
NULL,
NULL,
(DIGCF_PRESENT | DIGCF_INTERFACEDEVICE
));<br />
The device type GUIDS like DiskClassGuid come out of winioctl.h
If you get a neat solution working I suggest you write that article yourself. You'll be a CP hero in no time
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
When a user activates a window (in the program I am writing) I was wondering what message it sends and what function I can use to add some additional functionality when this happens.
Thanks for any tips.
|
|
|
|
|
|
Hey,
Thanks for that, I combined it with
<br />
<br />
HWND SetFocus(HWND hwnd)<br />
<br />
I was able to add my own functionality.
|
|
|
|
|
Your question is sort of ambigious since everything is technicaly a window, even the controls on a dialog. For those, handle the WM_SETFOCUS message. For "main" windows, handle WM_ACTIVATEAPP or WM_ACTIVATE . There's also WM_SETACTIVE for property pages.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I have a method which has to return the array of BSTRs. I'm giving the method here, please let me know if I'm doing anything wrong.
HRESULT Login([in] BSTR UserName, [in] BSTR Password, int maxUsrCnt , [out]int *UsrCnt, [out, length_is(,*UsrCnt), size_is(,maxUsrCnt)] BSTR *LoggedUsers);
the size of the array to be returned is not known at the time of calling.
When I use this method, the first string is coming properly, but other strings are not coming.
Please suggest an answer.
Regards,
Raja Pratap
|
|
|
|
|
I never need to output the array back yet. I only guess that the last parameter should be declared as "BSTR **LoggedUsers". It is because: to output single string, should use "BSTR*". To output an array of strings, logically it should be "BSTR**". If my guess is correct, let me know.
|
|
|
|
|
I Tried with BSTR**, could not succeed. Only first string comes, since the marshaller considers only the first string, since length is not mentioned.
I got a hint from one of CP members to use SAFEARRAY(BSTR)* that worked fine.
|
|
|
|
|
Hi all,
I would like to know how I can make use of ofstream to count the total lines within a file, without looping through the file.
Many Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: I would like to know how I can make use of ofstream to count the total lines within a file
Probably you need a istream .
Anyway you have to loop inside the file.
Using istream::getline may help.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thanks for the response CPallini ....
Like I said, I know one can do it in a loop. I.E
std::ifstream inFile;
inFile.open(lpfname, std::ios::in);
while (!inFile.eof())
{
inFile.getline(Str,STRING_SIZE);
lpzLineCounter++;
}
inFile.close();
Isn't there a single function that can perform the above code while using the fstream class??
Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: Isn't there a single function that can perform the above code while using the fstream class??
No (AFAIK).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
what about using the count_if()[^] algorithm with '\n' ?
|
|
|
|
|
I bet internally, though, that it uses a loop!
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
oh, yeah, certainly... but from our side, it's much simpler to write, so why bother, eh ?!
|
|
|
|
|
you will need to use ifstream and do the work yourself!
Yours Truly, The One and Only!
|
|
|
|
|
i want to use excel in my program, so i import mso97.dll. But i get an error:fatal error mso97.dll not found.
Kindly help!!.
|
|
|
|
|
Sammyuk wrote: But i get an error:fatal error mso97.dll not found.
Kindly help!!.
Does mso97.dll exist on your machine?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You import this file to your project but this error shows that you dont have this file on your system?
|
|
|
|
|
Kindly tell me as, is there any function to find the install path of MSOffice/Microsoft VC++. I tried SHGetFolderPath but in vain.
|
|
|
|
|
You could look in HKLM\SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot, assuming you are using Office 2003.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
harsha u wrote: I have to create a CFont object,with a perticulat size in points, of a perticular face type. I also want to specify the weight (Bold or not).
I have created a font using CFont::CreateFont(). But then i have to pass the size in terms of height and width (not in pt). I need to specify the size in pt.
Actually, it is very difficult to understand , what you are saying.
Probably, you can have a look at LOGFONT .
harsha u wrote: I have also tried this:
CFont *font;
font->CreatePointFont(120,"Arial",this->GetDC());
It is throwing an exception
It is because, you are using uninitialized pointer.
Prasad
MS MVP - VC++
|
|
|
|