Enumerating parallel ports

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Enumerating parallel ports

Post by Pablo César »

Dear Claudio,

I do not know what I am doing wrong. I have got Enumerating sub-keys with success values in FMG_Editor, but I can not get the same result with this one:

HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\PARALLEL PORTS

I tried with this code:

Code: Select all

Function Main()
Local cKey:="HKEY_LOCAL_MACHINE"
Local cSubKey:="HARDWARE\DEVICEMAP\PARALLEL PORTS"

Local aPorts:=EnumKeys( HKEY_LOCAL_MACHINE, cKey, cSubKey )
msgdebug(aPorts) //  I wish to get this sub-key value in \Device\Parallel0
Return Nil

Function EnumKeys(nKey,cKey,cSubKey)
Local hKey, cBuffer, n := 0, aRet:={}

#define KEY_READ 0x20019

If RegOpenKeyEx ( nKey, cSubKey, KEY_READ, @hKey )
   Do While RegEnumKeyEx ( hKey, n++, @cBuffer )
      AAdd(aRet,cBuffer)
   Enddo
   RegCloseKey( nKey )
Endif
Return aRet
I also tried with:

MsgDebug(RegistryRead("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\PARALLEL PORTS\Device\Parallel0"))

And

MsgDebug(RegistryRead("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\PARALLEL PORTS:\Device\Parallel0"))

But with no success. I saw some C examples, probably could help to understand better:

http://read.pudn.com/downloads3/sourcec ... ts.c__.htm (find for: m_szRegParallelMap)

http://www-user.tu-chemnitz.de/~heha/vi ... PP&lang=de (find for: DEVICEMAP\\PARALLEL PORTS)

I need to get if exists LPT1, LPT2... :(

Sometimes in some PC there is a multi/IO card installed which can assume LPT1 as LPT3, or LPT2... so I need to know first LPT available in the each PC.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Enumerating parallel ports

Post by mol »

I have this problem with serial ports on windows 7.
It works only when I'm logged in with administrator rights
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Enumerating parallel ports

Post by Pablo César »

mol wrote:I have this problem with serial ports on windows 7.
It works only when I'm logged in with administrator rights
I know it, Marek. (Here your post)

I'm working under WinXP and as administrator rights and with no success... :(
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Enumerating parallel ports

Post by andyglezl »

Hola Pablo Cesar, no se si te sirva esta Función:
-----------------------------------------
Hello Pablo Cesar, maybe you serve this function:


Code: Select all

FUNCTION ParallelPort()
	LOCAL obj, data1, oLocator, oWmi, oCollection
	
	oLocator := win_oleCreateObject( "wbemScripting.SwbemLocator" )
	oWmi     := oLocator:ConnectServer()
	data1:="Mi PC no tiene puertos Paralelos..."
	oCollection:= oWMI:ExecQuery("Select * from Win32_ParallelPort")
	For Each obj In oCollection
		cName        := PADL( 'Name:'  , 18)      + CHR(9) + obj:Name + CRLF
		cCaption     := PADL( 'Caption:'  , 18)   + CHR(9) + obj:Caption + CRLF
		cDescrip     := PADL( 'Description:', 18) + CHR(9) + obj:Description + CRLF
		
		// See Properties  ---------------     http://msdn.microsoft.com/en-us/library/aa394247(v=vs.85).aspx
		
		data1 += cName + cCaption + cDescrip
	Next
	MsgInfo( data1 )
RETURN nil
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Enumerating parallel ports

Post by Pablo César »

Genial ! Me sirve como un guante !

Muchas gracias, Andrés ! :D

Yo lo adapté y funciona perfecto. Solo tengo que probarlo con Win7 64bits tambien.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: Enumerating parallel ports

Post by Pablo César »

mol wrote:Is it usable for serial ports?
Yes !!!

I made this test and worked perfectly !!! :D

Code: Select all

// http://msdn.microsoft.com/en-us/library/aa394247(v=vs.85).aspx

#include <hmg.ch>

Function Main
MsgDebug(SerialPorts())
Return Nil

Function SerialPorts()
Local obj, oLocator, oWmi, oCollection
Local aPorts := {}

oLocator := win_oleCreateObject( "wbemScripting.SwbemLocator" )
oWmi     := oLocator:ConnectServer()
oCollection:= oWMI:ExecQuery("Select * from Win32_SerialPort")
For Each obj In oCollection
    AAdd(aPorts,{obj:Name,obj:Caption,obj:Description})
Next
Return aPorts
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Enumerating parallel ports

Post by danielmaximiliano »

Yes .. try
Inventory System (Software) - by AndyGlezL
06/06/2014
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Enumerating parallel ports

Post by andyglezl »

Re: Enumerating parallel ports
Yes .. try

Quote:
Inventory System (Software) - by AndyGlezL
06/06/2014
Y esto resulto de lo que posteaste Daniel, gracias. :D
---------------------------------------------------
And this resulted Daniel what you posted, thanks.


viewtopic.php?f=24&t=3488&p=32324#p32324
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: Enumerating parallel ports

Post by Pablo César »

andyglezl wrote:
Re: Enumerating parallel ports
Yes .. try

Quote:
Inventory System (Software) - by AndyGlezL
06/06/2014
Y esto resulto de lo que posteaste Daniel, gracias. :D
---------------------------------------------------
And this resulted Daniel what you posted, thanks.


viewtopic.php?f=24&t=3488&p=32324#p32324
Yes, yes !! Two problems solved thanks for your sharing Andrés and DanielMaximiliano !!!

Thank you guys, thank you very much to all of you. :D

Image Image
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply