hola , segue mi function que mostra as unidades , acho que lhe servirá.
Code: Select all
Function qualcamired
Local oDlg101,oWnd,ncodigo,cestacao,nquantas,ocoment,odlg2
local volta:="",obrw,area:=select()
nquantas :=0
ferase("carimp.dbf")
DbCreate( "CARIMP", { { "QUANTAS" , "N", 04, 0 },;
{ "NOME_IMP" , "C", 14, 0 },;
{ "ESTACAO" , "C", 23, 0 },;
{ "COMENTARIO", "C", 30, 0 } } )
if OpenFile( "carimp","carimp", 1, .F. )
endif
WAITRUN("COMMAND.COM /C net view > estacao.txt" ,0 )
DbCreate( "CARTES", { { "TEXTO", "C", 100, 0 } } )
if OpenFile( "cartes","cartes", 1, .F. )
endif
APPEND FROM estacao.txt SDF
dbselectarea("CARTES")
dbgotop()
Do while !eof()
if substr(CARTES->texto,1,2)#'\\'
dbskip(1)
loop
endif
dbselectarea('CARIMP')
cestacao :=substr(CARTES->texto,1,23)
ferase("ESTACAO.TXT")
WAITRUN("COMMAND.COM /C net view "+cestacao+" > estacao1.txt",0 )
DbCreate( "CARTIM", { { "TEXTO", "C", 100, 0 } } )
if OpenFile( "cartim","cartim", 2, .F. )
endif
APPEND FROM estacao1.txt SDF
dbselectarea("CARTIM")
dbgotop()
Do while !eof()
if substr(CARTIM->texto,14,4)#'Disc'.AND.substr(CARTIM->texto,14,4)#'Impr'
dbskip(1)
loop
else
if substr(CARTIM->texto,14,4)<>'Disc'
ocoment:="Impressora"
else
ocoment:="Disco"
endif
endif
dbselectarea('CARIMP')
append blank
nquantas++
replace CARIMP->quantas with nquantas
replace CARIMP->estacao with substr(CARTES->texto,1,23)
replace CARIMP->nome_imp with '\'+substr(CARTIM->texto,1,13)
replace CARIMP->comentario with ocoment
dbselectarea('CARTIM')
dbskip(1)
Enddo
dbselectarea('CARTIM')
dbclosearea('CARTIM')
ferase('CARTIM.DBF')
dbselectarea('CARTES')
dbskip(1)
Enddo
dbselectarea('CARTES')
dbclosearea('CARTES')
ferase('CARTES.DBF')
ferase('ESTACAO.TXT')
ferase('ESTACAO1.TXT')
dbselectarea('CARIMP')
go top
DEFINE DIALOG oDlg2 RESOURCE "REDE" TITLE "COMPONENTES DA REDE"
odlg2:lhelpicon:=.f.
REDEFINE LISTBOX obrw FIELDS carimp->NOME_IMP, ;
carimp->ESTACAO, ;
carimp->COMENTARIO ;
HEADERS OemToAnsi( "NOME" ), ;
OemToAnsi( "ESTACAO" ), ;
OemToAnsi( "DESCRICAO" ) ;
COLOR CLR_BLACK, rgb(238,221,130) ;
ID 101 ;
OF oDlg2 ;
ON DBLCLICK (volta:=rtrim(carimp->estacao)+rtrim(carimp->nome_imp),odlg2:end())
obrw:bKeyChar := {|nK| if( nK==VK_RETURN, (volta:=rtrim(carimp->estacao)+rtrim(carimp->nome_imp),odlg2:end()) ,NIL)}
activate dialog odlg2 centered
dbclosearea("carimp")
select(area)
Return volta