|
Your question intrigued me, as not long ago there were a series of articles / questions on
how impossible it was to enumerate serial ports...
I've done a little digging, and there are two functions that should interest you:
EnumPorts and EnumPrinters.
Here is some sample code for each:
DWORD dwNeed = 0;
DWORD dwPorts = 0;
BOOL b = EnumPorts (NULL, 2, NULL, dwNeed, &dwNeed, &dwPorts);
if (!b && GetLastError () == ERROR_INSUFFICIENT_BUFFER)
{
BYTE *buf = new BYTE [dwNeed];
memset (buf, 0, dwNeed);
PORT_INFO_2 *p = (PORT_INFO_2 *)buf;
b = EnumPorts (NULL, 2, buf, dwNeed, &dwNeed, &dwPorts);
delete [] buf;
}
dwNeed = dwPorts = 0;
b = EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 1, NULL, dwNeed, &dwNeed, &dwPorts);
if (!b && GetLastError () == ERROR_INSUFFICIENT_BUFFER)
{
BYTE *buf = new BYTE [dwNeed];
memset (buf, 0, dwNeed);
PRINTER_INFO_1 *p = (PRINTER_INFO_1 *)buf;
b = EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 1, buf, dwNeed, &dwNeed, &dwPorts);
delete [] buf;
}
You may also want to look at EnumMonitors, and the results different report levels give.
Iain.
|
|
|
|
|
Thank you. That's all I need
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Hello, everyone!
If I want to ask question about C/C++ under Linux environment. Can you introduce some forums?
regards,
George
|
|
|
|
|
this is a windows site
Don't try it, just do it!
|
|
|
|
|
Hi, Alexander buddy!
Linux is our future. Can you answer my question in a direct way?
Thanks in advance,
George
|
|
|
|
|
What do you want to know? What is Linux-specific about it? If it's about a library, ask on that libraries mailing list; if it's not Linux specific, ask here.
|
|
|
|
|
Thanks, roel_ buddy!
I want to ask IPC, PThread, memory management and device driver questions under Linux environment.
Do you know some forums?
regards,
George
|
|
|
|
|
Have you checked out any of the linux.dev.* newsgroups?
|
|
|
|
|
A very nice idea!
But are there some web based?
George
|
|
|
|
|
You can access them from Google.
|
|
|
|
|
Thanks, DavidCrow buddy!
George
|
|
|
|
|
You could start with http://leapster.org/linoleum/ (I admit, it's the second link when you type 'linux programming' in Google). Find some mailing lists to subscribe to, most development and support is on mailing lists and not on web-based boards in the Linux world (suggestion: get yourself a threading mail reader, like Mozilla Mail or even better, Mutt, it will greatly enhance your mailing list reading)
|
|
|
|
|
Thanks, roel_ buddy!
It is a very nice site!!
George
|
|
|
|
|
everybody knows what is the meaning of stdin, stdout, stderr, stdaux, and stdprm?
i just know those are standard input device, standard out device, and so on ...
but i don't have any idea(i don't understand) about standard input device, and its friends.
can somebody explain to me?
thousands thanx
>>when someone know more and more, they will feel they have weakness<<
|
|
|
|
|
They are io-streams that are opened by the runtime lib for you. Stdin is by connected to the console by default (but may be connected to some file with '<' on the command line.
Stdout is connected to to a console window on the screen by default, but can be redirected to a file with '>' on the command line.
Stderr is by default connected like stdin , but can not be redirected.
I hope this could help you a bit.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Those are just streams! just like any files streams, memory streams,...
You should find all the information you need in the MSDN library
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
I want to achieve the following:
Suggest you have a property sheet with three property pages which all have a combobox named IDC_COMBOBOX. The comboboxes named IDC_COMBOBOX, all have te same items stored in it. The list of items is large, so it takes a wile to put (initialize) all the items into the combobox. Therefore I want all the three comboboxes to share the same list of items, so that I only have to initialize one time to get all the three comboboxes filled with the same items.
How can I achieve this?
Is there a way to access the storage of the combobox from another dialog?
Thnxx
|
|
|
|
|
harmendejong wrote:
Is there a way to access the storage of the combobox from another dialog?
yes.
first of all, you should determine DDX object for your control(m_combo) in CYourDialog1 and then you can access to control from other dialog that follow this.
CYourDialog1 dlg;<br />
dlg.m_combo......
|
|
|
|
|
On that way I can access the data of the other combobox, but actually I want al the (three) comboboxes to act like they are the same. So if I've added a large list of items to combobox1, then combobox2 and combobox3 must automatically have that items too without having to load the large list of items into their storage area in the memory. I think this could be done if they all use the same area of memory for the storage of their items.
How can this be done???
|
|
|
|
|
harmendejong wrote:
Is there a way to access the storage of the combobox from another dialog?
No, you can't have two combo boxes share the same data. However, to speed up the loading process, use SetRedraw() on the combo boxes (if you're using MFC, send the WM_SETREDRAW message to the combo box if you're not) to prevent the combo box updating itself after each addition. Remember to call it again when you've finished loading data to enable updating again, and then call Invalidate() on the combo box.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Correct me if I am wrong, but he can create a combo box at run time, initialize it, hide it, and then whenever a dialog gets the focus or created he can show that combo box at the appropriate position. I have done something similar (not exactly the same) with edit boxes on a grid but I kind of aborted the project (for other reasons). It requires some work and it might not be very feasible.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Can you please give me some sample code of what you mean??
Thnxx
|
|
|
|
|
That was just an idea harmendejong so I really don't have any source code (I don't even know if it works).
But here is a general idea of how it might be implemeted (the code has not been tested at all, and it needs to be modified to work).
CRect aRect( 0, 0, 10, 10 );
m_cmbMyCombo.Create(WS_CHILD | WS_VISIBLE |
CBS_DROPDOWNLIST,
aRect, this, IDC_MYCOMBO );
...
m_cmbMyCombo.ShowWindow( SW_HIDE );
aRect = SomeArea;
m_cmbMyCombo.SetParent( this );
m_cmbMyCombo.MoveWindow( &aRect );
m_cmbMyCombo.ShowWindow( SW_SHOW );
m_cmbMyCombo.SetFocus();
You have to make sure that you hide and show your combo box accordingly. You won't be able to handle the events through the class wizard (unless you create your own combo class derived from CComboBox). Also, you have to make sure that you destroy the combo box at the end.
Sorry, I can't help you anymore because this is something that I haven't tested but I hope that it gives you some ideas on how to proceed.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Yes, it's technically possible, but it's a logistical nightmare . It's a bit more difficult that moving one edit box around on a single page.
All the combo box messages are sent to the parent of the combo box, such as selection change, edit change, focus change etc. Yes, the parent can be changed dynamically to the different pages (using SetParent() ) but it's not much more than a hack, and makes it virtually impossible to use ClassWizard (not much of a limitation, but depending on his skill with VC++ it may be).
The selection of the combo box can be different on each page, and will need to be saved and restored every time a new page is displayed.
Basically, it's more work to keep track of one combo box on multiple pages than it is to try to speed up the loading process.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
harmendejong wrote:
Suggest you have a property sheet with three property pages which all have a combobox named IDC_COMBOBOX. The comboboxes named IDC_COMBOBOX, all have te same items stored in it. The list of items is large, so it takes a wile to put (initialize) all the items into the combobox. Therefore I want all the three comboboxes to share the same list of items, so that I only have to initialize one time to get all the three comboboxes filled with the same items.
How can I achieve this?
Have the property sheet keep the data in a list or array of some sort. Then in the OnSetActive() method of each property page, populate its combobox with the data from the property sheet. Make sense?
|
|
|
|
|