forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Pull printers from registry

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 4 Source Code
View previous topic :: View next topic  
Author Message
LOBO
Valued Contributor
Valued Contributor


Joined: 14 Mar 2002
Posts: 241
Location: Wilmington, Delaware, USA

PostPosted: Tue Mar 18, 2003 7:11 pm    Post subject: Pull printers from registry Reply with quote

This example is from a program I am working on and uses both MT.dll & VDSLists.dll as I took this out of a program I am working on.

Code:

Rem ===========================================================================
Rem              Example using of pulling printers from registry
Rem                                By LOBO
Rem                   This code uses MT.dll & VDSLists.dll
Rem                     Thought this might help someone
Rem                    Feel free to use code how you like
Rem ===========================================================================

directory change,@path(%0)
  external vdslists.dll
  external mt.dll
  OPTION SCALE,96
  option fieldsep,@chr(44)
  option decimalsep,.
  extlist fieldsep,|
 
Title New
  DIALOG CREATE,Printers from registry example,-1,0,433,161,class printerexample
  DIALOG ADD,MENU,File,Exit
  DIALOG ADD,BUTTON,Run,112,88,64,24,Run
  DIALOG ADD,BUTTON,Exit,112,288,64,24,Exit
 
  extlist window,#printerexample
  extlist add,style,style1,Arial,8,B,,
  extlist distance,4
  extlist add,collist,printlist,15,0,424,96,Printer Name|165@cr()Printer Port|165@cr()Default|90,style1
  extlist add,status,status,16,140@cr()135@cr()158,,style1
 
  DIALOG SHOW
  goto timer
 
:Evloop
  wait event,1
  goto @event()
 
:timer
  extlist set,status,@datetime(mmm d"," yyyy   h:nn ampm )@cr()Printers: %%nprinters@cr()Example by: LOBO"
  goto evloop

:RunBUTTON
  list create,2
  if @equal(@mt(os,platform),2)
  gosub nt
  else
  gosub 9x
  end
  gosub printers 
  goto evloop

:ExitBUTTON
:ExitMENU
:Close
  exit
 
Rem ------------ Sub Routines ---------------------
:9x
  LIST REGKEYS,2,LOCAL,System\CurrentControlSet\Control\Print\Printers
  parse "%%defpname",@regread(LOCAL,Software\Microsoft\Windows\CurrentVersion\Windows,Device)
  exit
:nt
  LIST REGKEYS,2,LOCAL,System\CurrentControlSet\Control\Print\Printers
  LIST REGKEYS,2,CURUSER,Printers\Connections
  parse "%%defpname",@regread(CURUSER,Software\Microsoft\Windows NT\CurrentVersion\Windows,Device)
  exit
 
:printers
  %%nprinters = @count(2)
  if @equal(%%nprinters,-1)
  extlist list,add,printlist,No printers were found in the registry@tab()@tab()
  else
  %%start = 0
  repeat
  %%pnetwork = 0
  LIST SEEK,2,%%start
  %%prntname = @item(2)
  %%prntport = @regread(LOCAL,System\CurrentControlSet\Control\Print\Printers\%%prntname,Port)
rem checks for network printer in registry and changes , in entries to \
  if @equal(@substr(%%prntname,1,2),@chr(44)@chr(44))
  %%pnetwork = @succ(%%pnetwork)
    %%Line = %%prntname
   %%Step = 1
    Repeat
      %C = @Substr(%%Line,%%Step,%%Step)
      If @Equal(%C,",")
        %%Line = @strdel(%%Line,%%Step,%%Step)
      %%Line = @strins(%%Line,%%Step,\)
      End
      %%Step = @Succ(%%Step)
    Until @Equal(%%Step,@Len(%%Line))
end
if @equal(%%pnetwork,1)
%%prntname = %%Line
%%prntport = %%Line
end
if @equal(%%defpname,%%prntname)
extlist list,add,printlist,%%prntname@tab()%%prntport@tab()yes
else
extlist list,add,printlist,%%prntname@tab()%%prntport@tab()
end
%%start = @succ(%%start)
until @equal(%%nprinters,%%start)

end
exit


Regards,
Mark
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sat Mar 22, 2003 9:54 pm    Post subject: Reply with quote

Thanks, LOBO. This might come in handy some day. Very Happy
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
LOBO
Valued Contributor
Valued Contributor


Joined: 14 Mar 2002
Posts: 241
Location: Wilmington, Delaware, USA

PostPosted: Sat Mar 22, 2003 11:08 pm    Post subject: Reply with quote

You're very welcome Smile
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 4 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group