|
Dear All,
I am having a USB serial device and I want to create handle to the device whenever the device is connected.
I want to open the handle using VID and PID of the USB serial device. I tried using SetupDi calls but not detecting the ports. The below is my code snippet. Please help me to solve this issue.
bool status = false;
bool bRet = false;
HDEVINFO devInfoSet = INVALID_HANDLE_VALUE;
SP_DEVICE_INTERFACE_DATA pDeviceData;
SP_DEVINFO_DATA devInfoData;
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
DWORD index = 0;
ULONG i=0;
ULONG requiredLength=0;
pDeviceData.cbSize = sizeof(SP_INTERFACE_DEVICE_DATA);
devInfoSet =SetupDiGetClassDevs(&GUID_DEVINTERFACE_COMPORT,NULL,NULL,(DIGCF_PRESENT | DIGCF_DEVICEINTERFACE) );
if(devInfoSet!=INVALID_HANDLE_VALUE)
{
while(TRUE)
{
bRet = SetupDiEnumDeviceInterfaces(devInfoSet, NULL,
&GUID_DEVINTERFACE_COMPORT, index,
&pDeviceData );
int x = GetLastError();
if(bRet)
index++;
else
break;
}
}
|
|
|
|
|
Hi,
I have some problems with the edit control. I want to count the chars if it, but the message i send to the control only receives the right character num for the first line.
For exmaple. The first line can have 60 chars. If I only enter 50 or so, the message gives me the right count. If I then enter a longer text, so that the first line have all the 60 chars and the second line have only 30 chars, then the message returns also a number of 60 chars for the second line, but why ? Where is the problem ?
My line:
dwChars = (DWORD)SendDlgItemMessage(hwnd,IDC_INPUT,EM_LINELENGTH,(WPARAM)3,(LPARAM)0);
I hardcoded the line 3 here, normally I am going through a for loop.
|
|
|
|
|
Okay i found the error. I think the wparam needs the offset of the char in the complete edit field. So I first sent the EM_LINEINDEX message and now I thinks its working.
|
|
|
|
|
EM_LINELENGTH message wants the index of a character (of the wanted line) as WPARAM , hence, if you need the lenght of the third line, use:
INT iCharIndex = SendDlgItemMessage(hwnd,IDC_INPUT,EM_LINEINDEX,(WPARAM)2,(LPARAM)0);
INT iLineLen = SendDlgItemMessage(hwnd,IDC_INPUT,EM_LINELENGTH,(WPARAM)iCharIndex,(LPARAM)0);
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi All
How can i use short cut key for open and close dialog box?Plz help me
|
|
|
|
|
|
Normally and SDI an application mainframe can split using splitterWnd from CMainFrame,
Can i split the new fromview in the same application which is not the main view
|
|
|
|
|
Cant you code it explicitly using a static splitter?
|
|
|
|
|
Hi' I'm new to C++?
This code to show current date.
#include <iostream.h>
#include "string.h"
#include "time.h"
#include <stdlib.h>
int main()
{
tdclass TimeDateClass;
cout<<"Today is "<<TimeDateClass.date()<<endl;
system("pause");
}
How to compare date we input and compare is it less or more from the current date?
Tq
|
|
|
|
|
One idea is to convert the dates to corresponding number of days and compare.
|
|
|
|
|
Can you show me more details!
|
|
|
|
|
For example,
days1 = day1 + month1*31 + year1*365;
days2 = day2 + month2*31 + year2*365;
if( days1 > days2 )
{
do something
}
else
{
do something
}
|
|
|
|
|
You can use COleDateTime[^] class. It have comparison operators such as ==, <, <=, etc[^] which can be used for comparison.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi,
Using synchronization object, I can restrict the number of instances of my application to one. How can I achieve the same, when the system is on network?
|
|
|
|
|
What about broadcasting a custom UDP message over the network? If any of your application is running over somewhere in the network, sent back another reply.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
What exactly do you mean by system is on network ?
- Malli...!
modified on Friday, December 12, 2008 2:38 AM
|
|
|
|
|
Hmmm - is it possible that you want to achieve this so you can ensure there's only one person accessing a resource on the network somewhere? If it's a file, you could try locking the file appropriately...or you could do the job the safe and assurable way, and hide the resource behind a server, so the server is the only thing that can access it, giving you control again.
|
|
|
|
|
Hi Friends,
I have two NT services running on my machine.NTService1 is dependent on NTService2.
When i was trying to debug the code related to NTService2,i tried attach to process. But the process related to NTService2 is always grayed out.
This is happening only on Vista machine.
I tried searching the Microsoft forums,but could not find a solution.
Any help is appreciated.
Thanks in Advance.
Appu..
"Never explain yourself to anyone.
Because the person who likes you does n't need it.
And the person who dislikes you won't believe it."
|
|
|
|
|
Visual Studio needs to run with elevated privileges to attach to processes...
Are you doing that?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes..I am doing that.
Appu..
"Never explain yourself to anyone.
Because the person who likes you does n't need it.
And the person who dislikes you won't believe it."
|
|
|
|
|
Hi all,
I m using a ListCtrl of ReportView type.
i have 5 coloumns here.
i want to add checkbox or button in header or in coloumn 4.
please tell me how can i do this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
See here[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
thanks i m already check this article.
this is use number of project in ne application and it is not working properly,
this is use number of class for this.
i have already derived me listctrl from other class.
there is any other easy way to implement this.
please help me.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Did you check this article[^]? Please read section - 2. Adding check box for head ctrl .
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
I want to add check box other than first coloumn.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|