EnumPorts () returns a strange error on some machines

I support an application that uses the win32 EnumPorts () function to help determine the set of serial ports installed on the computer. I saw cases on some computers where the call to get this information failed with the GetLastError () code of 1722 (the RPC server is unavailable). I suppose this has something to do with registry settings or a disabled service, but my search so far has been pretty fruitless. Has anyone else encountered this problem?

In response to Euro Michelli's comments. I specifically try to populate a selection list that will allow the user to select an available selection list. For starters, I relied solely on EnumPorts () to provide me with a list of potential serial port names. This turned out to be unreliable, but in several ways: it did not always provide the full set of port names, and, as I recently saw, it may not work at all when the "RPC service is unavailable." Why is RPC necessary to find out which ports are available on the local computer, completely outside of me, but it is. This last problem was the last straw. Since I completely rely on the list of names provided, I filter these names using the GetDefaultCommConfig () function to determine the exact nature of each of the names I came up with.

In my experience, the list of names provided by the previously mentioned registry key was the most reliable method of obtaining port names. In fact, I see that the key is being updated as I have disabled port drivers in Device Manager. In normal experience, I agree with the assessment that relying on a particular key is fraught with danger. In this case, however, M $ never provided a decent mechanism for evaluating the names of available ports.

I should note that I have already replaced the call to EnumPorts () with an algorithm that scans the registry key: HKEY_LOCAL_MACHINE \ HARDWARE \ DEVICEMAP \ SERIALCOMM for serial port names. This should fix the problem after the release of my software. What I need are pointers that can be provided to clients who currently use the released package.

+3
4

EnumPorts, .

  • .
  • , .
  • " ", .
  • .. ..

API.

API , , . , :

?

+1

: USB-, Bluetooth, GPS,... , - .

, , , " " "" , . .

0

, , ? API , - PJ Naughter: http://www.naughter.com/enumser.html, , .

0

, , , .

The reason for RPC is that you call the spooler function β€” you ask the print spooler to return a list of printer ports, which in most cases includes COM ports. I believe this may explain your slight unreliable results.

RPC is used to send a request from your process to the active process of the buffering queue, and a message RPC Server is unavailableoccurs when the spooler service is down (or not responding properly).

0
source

Source: https://habr.com/ru/post/1698049/


All Articles