Article View: borland.public.delphi.nativeapi
Article #12163Re: Enumports
From: Carlos Azevedo
Date: Fri, 22 Nov 2002 17:25
Date: Fri, 22 Nov 2002 17:25
67 lines
2644 bytes
2644 bytes
Thanks. -- Carlos Azevedo Supervisor T๏ฟฝcnico carlos@sector.com.br "Adrian Hunt" <adrianhunt@myriadworld.REMOVE_THIS.com> escreveu na mensagem news:3dde62dd$4@newsgroups.borland.com... > > Hi > > Hope this example helps... Easier then explaining!! B) > > Adrian > > ---- > > Uses > WinSpool; > > Type > TArrayPORT_INFO_1 = Array[0..0] Of PORT_INFO_1; > PArrayPORT_INFO_1 = ^TArrayPORT_INFO_1; > > procedure LPT1Check(); > Var > apiBuffer: PArrayPORT_INFO_1; > lwBufferSize: LongWord; > lwPortCount: LongWord; > lwIndex: LongWord; > sMessage: String; > begin > // Find required size of the buffer > EnumPorts(Nil, 1, Nil, 0, lwBufferSize, lwPortCount); > > // Alloc and fill buffer > apiBuffer := AllocMem(lwBufferSize); > EnumPorts(Nil, 1, apiBuffer, lwBufferSize, lwBufferSize, lwPortCount); > > // Search returned buffer > // Using word so must check for 0 as 0 - 1 = 4294967295 not -1! > If lwPortCount = 0 Then > sMessage := 'No ports installed on this system' > Else > Begin > sMessage := 'LPT1: not found on this system'; > > For lwIndex := 0 To lwPortCount - 1 Do > Begin > If UpperCase(apiBuffer[lwIndex].pName) = 'LPT1:' Then > Begin > sMessage := 'LPT1: exists'; > Break; > End; // If name > End; // For lwIndex > End; // If lwPortCount > > // Free the buffer and show result > FreeMem(apiBuffer); > ShowMessage(sMessage); > end; > > > "Carlos Azevedo" <carlos@sector.com.br> wrote: > >How to use the function Enumports to discover if the LPT1 port is install? >
Technical Details
Message-ID:
<3dde6886@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mailReferences:
<3dde241e@newsgroups.borland.com> <3dde62dd$4@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f94dd,e4085bbbbd7e21cd X-Google-Attributes: gidf94dd,public X-Google-ArrivalTime: 2002-11-22 10:15:46 PST From: "Carlos Azevedo" <carlos@sector.com.br> Newsgroups: borland.public.delphi.nativeapi References: <3dde241e@newsgroups.borland.com> <3dde62dd$4@newsgroups.borland.com> Subject: Re: Enumports Date: Fri, 22 Nov 2002 15:25:02 -0200 Lines: 69 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 200.179.224.158 Message-ID: <3dde6886@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1037985926 200.179.224.158 (22 Nov 2002 09:25:26 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mail