|
Good afternoon!
lets assume that my computer has following ports
COM1, COM2, ....COM11, COM12, .. COM20.
now i have connected a Pendrive in COM1, a Printer in COM11.
so how can i get list of all other free ports such as COM2,COM3 ...Com10
COM12, COM13...COM20 programmatically?
|
|
|
|
|
You can find it here[^]">
Regards,
Rane
|
|
|
|
|
Can u please suggest some simple ways or some msdn library functions
that will do the work , i need them in visual c++.
-thanks
|
|
|
|
|
What's wrong with Rane's suggestion?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I understand your question as "the ports are physically there but how can I know if they are in use", which is quite different from listing the ports present in the system.
I've understood your question correctly, the answer is that you cannot do what you desire, based on simple logic:
In case of real RS232-UARTs the system doesn't know if you have attached something in the other end of a serial device since no communication is done until you open an application and tell it that you want to communicate with a certain port. The user have to keep track of which port he/she has connected the device to.
In case of the port being a virtual COM port such as a USB device, the COM port assigned to the device will not be present in the system until the device is attached. Then you have the same situation as with real COM ports; you use an application that opens the port with ::CreateFile() .
Any application can open a port provided that the device name is known and for this you may enumerate the ports present in the system and for which you've already been given an answer.
From the machine's perspective a "free port" in the sense I've interpreted your question does not exist.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hai !
Currently i am working with ::CreateFile()
in the following format
I am sending name of each COM port and Testing whether it is avilable or not
m_ihandle = CreateFile(Port, GENERIC_READ | GENERIC_WRITE,
0, 0,OPEN_EXISTING, 0, 0);
//if the handle value is -1, that means you got an error....
if(m_ihandle == -1)
AfxMEssageBox("open COM port failed");
else
//write success log
AfxMessageBox("opened successfully!");
But my requirement is different, without testing in this format, i simply want to load only avilabe ports to my combobox rather than picking each port from combobox and testing it!!
|
|
|
|
|
kapardhi wrote: But my requirement is different, without testing in this format, i simply want to load only avilabe ports to my combobox rather than picking each port from combobox and testing it!!
As I said; you cannot do that since the system doesn't keep track of devices that are currently in use.
Compare it with opening a file, even the name of the function suggests that the comparison makes sense. You cannot determine whether the file is currently in use or not prior to trying to open it. If the file is in use and is opened with exclusive access, you'll get a sharing violation and the call to ::CreateFile() fails the same way it would fail when trying to open a COM port if the port is in use by another application.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
what is difference between "StretchBlt and BitBlt".
If i am try to zoom in the image in SDI application (in Visual Studio 2008) through bitBlt, the image is not zooming. Same code i just replace the "StretchBlt" instead of "BitBlt" then the image in the window is zooming correctly.
could anyone explain why it happen.
|
|
|
|
|
from documentation
StretchBlt
The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
BitBlt
The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
Hi ,
So it is not possible to zoom the image through BitBlt in mfc 9.0 ?
|
|
|
|
|
Why you don't want to use StretchBlt.
I dont think it is possible to zoom with BitBlt.
Regards,
Sandip.
|
|
|
|
|
i am thinking of performance(both execution and memory). In performance wish which is best?.
In vc++ 6.0 i am using the BitBlt to zoom the image, but in vc++ 9.0 (mfc 9.0) i am not able to zoom the image through bitblt.
so i need to use stretchBlt to zoom the image in mfc 9.0?.
Thanks your reply.
|
|
|
|
|
Bernaad wrote: In vc++ 6.0 i am using the BitBlt to zoom the image,
How? BitBlt doesn't have any parameters to change the destination size.
BitBlt hasn't changed since way before VC6...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
大家好!
怎么取得当前使用的计算机的用户名呢?
a beginner
|
|
|
|
|
大家 取得取得!!!
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
dick head, we speak english here (if you hadn't notice yet)...
BTW, have you seen this[^] ??
|
|
|
|
|
sorry ,I forgot
i want to know how can i get current user who is using the computyer 's name by API
a beginner
|
|
|
|
|
|
GetComputerName()
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
Which is completely different than GetUserName() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
|
When calling someone a loser, it's VERY important to
spell it right. Unless, of course, you meant "looser"...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
nope, i meant "Loooooooooooser"... get it ?
|
|
|
|
|
I don't get it. Get it?
Loooooooooser is much better.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
can that be in english?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|