Discussion:
[Lazarus] devmgmt.msc
duilio foschi via Lazarus
2018-03-28 20:48:46 UTC
Permalink
if I run devmgmt.msc on W7 I get this info on screen:

Loading Image...

Is there a Winows API I can call from my Lazarus program and get the same info ?

My aim is to detect which COM number was assigned to the USB device
"MSP Application UART1"

Thank you

Peppe
--
José Mejuto via Lazarus
2018-03-29 12:22:00 UTC
Permalink
Post by duilio foschi via Lazarus
Is there a Winows API I can call from my Lazarus program and get the same info ?
My aim is to detect which COM number was assigned to the USB device
"MSP Application UART1"
Hello,

Attached unit will help you to implement a COM port browsing. There is a
bit of extra code as original comes from a bigger unit, and this is an
extract.


--
duilio foschi via Lazarus
2018-03-30 13:43:42 UTC
Permalink
Hi Jose',

thank you for the code, but

1. I get a number of error messages while compiling the unit with
Lazarus 1.6.4 under W7 (see below)
2. I cannot understand how I can get the enumerated COM device names
into a TStringList as I need to process the names.

Thank you

Peppe


Compile Project, Target:
C:\Users\PCCE88~1.BUF\AppData\Local\Temp\project1.exe: Exit code 1,
Errors: 11
udeviceenumwin.pas(83,22) Error: Identifier not found "TLibHandle"
udeviceenumwin.pas(83,32) Error: Error in type definition
udeviceenumwin.pas(164,23) Error: Operator is not overloaded:
"<erroneous type>" = "ShortInt"
udeviceenumwin.pas(165,88) Error: Incompatible type for arg no. 1: Got
"<erroneous type>", expected "QWord"
udeviceenumwin.pas(166,96) Error: Incompatible type for arg no. 1: Got
"<erroneous type>", expected "QWord"
udeviceenumwin.pas(167,101) Error: Incompatible type for arg no. 1:
Got "<erroneous type>", expected "QWord"
udeviceenumwin.pas(168,97) Error: Incompatible type for arg no. 1: Got
"<erroneous type>", expected "QWord"
udeviceenumwin.pas(169,102) Error: Incompatible type for arg no. 1:
Got "<erroneous type>", expected "QWord"
udeviceenumwin.pas(170,90) Error: Incompatible type for arg no. 1: Got
"<erroneous type>", expected "QWord"
udeviceenumwin.pas(184,26) Error: Operator is not overloaded:
"<erroneous type>" = "ShortInt"
udeviceenumwin.pas(184,65) Error: Incompatible type for arg no. 1: Got
"<erroneous type>", expected "QWord"
Post by José Mejuto via Lazarus
Post by duilio foschi via Lazarus
Is there a Winows API I can call from my Lazarus program and get the same info ?
My aim is to detect which COM number was assigned to the USB device
"MSP Application UART1"
Hello,
Attached unit will help you to implement a COM port browsing. There is a bit
of extra code as original comes from a bigger unit, and this is an extract.
--
--
José Mejuto via Lazarus
2018-03-30 16:34:53 UTC
Permalink
Post by duilio foschi via Lazarus
thank you for the code, but
1. I get a number of error messages while compiling the unit with
Lazarus 1.6.4 under W7 (see below)
2. I cannot understand how I can get the enumerated COM device names
into a TStringList as I need to process the names.
Hello,

I'm unable to understand how you get the first error :-? TLibHandle is
in system unit which is mandatory, so I do not know how to you can get
an "Identifier not found" :-?

Anyway, attached you can get a project sample, so you can process the
data. You can extract the COM number from the name displayed.

--
duilio foschi via Lazarus
2018-03-30 20:45:21 UTC
Permalink
Hi Jose',

doubting a configuration error, I uninstalled Lazarus, then installed
it again (current version is 1.8.2).

Unfortunately I could not get rid of the error on TLibHandle.

Then I found out that this type (TLibHandle) is not declared in
system.pas but in rtl/dynlibs.pas

Loading Image...

I fixed the problem by adding dynlibs.pas to the project.

Unfortunately when I compile the code I get new error messages (see
below) in unit lnfodwrf.

See

Loading Image...

Well, I am sure I will fix all problems before or later :)

Thank you

Peppe


lnfodwrf.pp(846,23) Error: Incompatible types: got "<address of
function(Pointer):AnsiString;Register>" expected "<procedure variable
type of function(Pointer):ShortString;Register>"
--
José Mejuto via Lazarus
2018-03-31 18:34:18 UTC
Permalink
Post by duilio foschi via Lazarus
Hi Jose',
doubting a configuration error, I uninstalled Lazarus, then installed
it again (current version is 1.8.2).
Unfortunately I could not get rid of the error on TLibHandle.
Then I found out that this type (TLibHandle) is not declared in
system.pas but in rtl/dynlibs.pas
Hello,

You have a somehow corrupted Lazarus/fpc installation. Ensure that your
Lazarus configuration points to the right fpc executable, or start a
configuration from scratch using the "--pcp" executable parameter.
Something like "Lazarus.exe --pcp C:\Lazarus\CleanConfig"

TLibHandle is defined in "sysdlh.inc" which is included by "dynlibh.inc"
which is included by "system" unit in Windows platform.

Also you get a compilation error in the dwarf support which has been
included long time ago, so your Lazarus configuration is pointing to an
old fpc 2.2 or something like that.
--
--
Loading...