PCs en la red
-
- Posts: 145
- Joined: Fri Oct 21, 2005 6:35 pm
PCs en la red
Hola a todos.
Estoy buscando alguna funcion que me devuelva el nombre de todas las pc que esten en la red local, encuentro NetName() del viejo clipper pero solo me da el nombre de la PC local. Gracias.
Jorge Jaurena
Estoy buscando alguna funcion que me devuelva el nombre de todas las pc que esten en la red local, encuentro NetName() del viejo clipper pero solo me da el nombre de la PC local. Gracias.
Jorge Jaurena
- jrestojeda
- Posts: 543
- Joined: Wed Jul 04, 2007 3:51 pm
- Location: Buenos Aires - Argentina
Re: PCs en la red
Hola Jorge,
¿Cómo andás?
No se si existe algo armado...
Pero podrías armarla vos mismo volcando el comando NET VIEW en un archivo de texto y luego leerlo con un memoread.
Espero te sirva la idea...
Saludos,
¿Cómo andás?
No se si existe algo armado...
Pero podrías armarla vos mismo volcando el comando NET VIEW en un archivo de texto y luego leerlo con un memoread.
Espero te sirva la idea...
Saludos,
Last edited by jrestojeda on Wed Oct 29, 2014 6:25 pm, edited 1 time in total.
Ojeda Esteban Eduardo.
Buenos Aires - Argentina.
FWH - PellesC - DBF/CDX - ADS - Gloriosos .Bat - MySql - C# .net - FastReport
Skype: jreduojeda
Buenos Aires - Argentina.
FWH - PellesC - DBF/CDX - ADS - Gloriosos .Bat - MySql - C# .net - FastReport
Skype: jreduojeda
- jrestojeda
- Posts: 543
- Joined: Wed Jul 04, 2007 3:51 pm
- Location: Buenos Aires - Argentina
Re: PCs en la red
Jorge...
Probá esta función que armé al voleo...
Espero sea lo que estabas buscando.
Saludos,
Probá esta función que armé al voleo...
Code: Select all
// PRUEBA LISTADO DE PCS DE UNA RED //
Function DemoNetView()
Local aPCs:={}
WAITRUN( "cmd.exe /c net view > C:\PCs.txt" , .t.)
cTexto :=MEMOREAD( "C:\PCs.txt" )
nLinea :=MLCOUNT(cTexto)
FOR Q=4 TO nLinea // Arranca de la línea 4 (De todos modos probalo)
cLinea:=MEMOLINE(cTexto,255,Q)
IF LEFT(clinea,2)="\\"
AADD(aPCs,ALLTRIM(LEFT(cLinea,23)))
MsgInfo(ALLTRIM(LEFT(cLinea,23)))
ENDIF
NEXT
FErase("C:\PCs.txt")
Return nil
//
Saludos,
Last edited by jrestojeda on Wed Oct 29, 2014 6:50 pm, edited 1 time in total.
Ojeda Esteban Eduardo.
Buenos Aires - Argentina.
FWH - PellesC - DBF/CDX - ADS - Gloriosos .Bat - MySql - C# .net - FastReport
Skype: jreduojeda
Buenos Aires - Argentina.
FWH - PellesC - DBF/CDX - ADS - Gloriosos .Bat - MySql - C# .net - FastReport
Skype: jreduojeda
Re: PCs en la red
João Santos - São Paulo - Brasil
Re: PCs en la red
Aquí otra forma
Saludos,
Adhemar
Code: Select all
FUNCTION ListPC()
LOCAL oAdoCommand,oAdoConnection,oRs
oAdoCommand:=CreateObject("ADODB.Command")
oAdoConnection:=CreateObject("ADODB.Connection")
oAdoConnection:Provider:="ADsDSOObject"
oAdoConnection:Open("Active Directory Provider")
oAdoCommand:ActiveConnection:=oAdoConnection
oAdoCommand:CommandText:="Select name from 'LDAP://DOMINIO' Where objectCategory='computer'" //COLOCAR EL DOMINIO O EL GRUPO DE LA RED
oRs:=oAdoCommand:Execute()
oRs:MoveFirst()
DO WHILE !oRs:Eof()
xPC:=Alltrim(oRs:Fields("Name"):Value)
aAdd(aPcs,xPC)
oRs:MoveNext()
ENDDO
RETURN NIL
Adhemar
Saludos,
Adhemar C.
Adhemar C.
Re: PCs en la red
Adhemar, que hago mal?
Gracias, saludos.
Code: Select all
Application
===========
Path and name: C:\FWH1306\samples\TESTE.exe (32 bits)
Size: 2,467,328 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20140725)
Error description: Error ADODB.Command/6 DISP_E_UNKNOWNNAME: EXECUTE
Args:
Stack Calls
===========
Called from: => TOLEAUTO:EXECUTE( 0 )
Called from: TESTE.prg => LISTPC( 24 )
Called from: TESTE.prg => MAIN( 7 )
Linea 24:
oRs:=oAdoCommand:Execute()
João Santos - São Paulo - Brasil
-
- Posts: 145
- Joined: Fri Oct 21, 2005 6:35 pm
Re: PCs en la red
Te paso la version corregida y probada.
Function HNetView()
Local aPCs:={}
Local cTexto,nLinea,cLinea,Q
WAITRUN( "cmd.exe /c net view > PCs.txt" , .t.)
cTexto :=MEMOREAD( "PCs.txt" )
nLinea :=MLCOUNT(cTexto)
FOR Q=1 TO nLinea // Arranca de la línea 4 (De todos modos probalo)
cLinea:=MEMOLINE(cTexto,255,Q)
IF LEFT(clinea,2)="\\"
AADD(aPCs,ALLTRIM(LEFT(cLinea,23)))
ENDIF
NEXT
Return aPCs
La llamas asi:
Array:=HNetView()
Y funciona bien, Gracias.
Function HNetView()
Local aPCs:={}
Local cTexto,nLinea,cLinea,Q
WAITRUN( "cmd.exe /c net view > PCs.txt" , .t.)
cTexto :=MEMOREAD( "PCs.txt" )
nLinea :=MLCOUNT(cTexto)
FOR Q=1 TO nLinea // Arranca de la línea 4 (De todos modos probalo)
cLinea:=MEMOLINE(cTexto,255,Q)
IF LEFT(clinea,2)="\\"
AADD(aPCs,ALLTRIM(LEFT(cLinea,23)))
ENDIF
NEXT
Return aPCs
La llamas asi:
Array:=HNetView()
Y funciona bien, Gracias.
-
- Posts: 65
- Joined: Tue Apr 14, 2009 9:26 pm
- Location: Brasil
Re: PCs en la red
hola, mira mi funcion :
Saludos
William Adami
Code: Select all
Function qualmaq
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" )
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" )
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
William Adami
Re: PCs en la red
William, pode postar esta função:
Obg. abs,
Code: Select all
if OpenFile( "carimp","carimp", 1, .F. )
endif
João Santos - São Paulo - Brasil
-
- Posts: 65
- Joined: Tue Apr 14, 2009 9:26 pm
- Location: Brasil
Re: PCs en la red
Hola Joao , segue abaixo:
FUNCTION OpenFile( cFile, cAlias, nModo, lRetenta )
DEFAULT cAlias TO Subs( cFile, rAt( '\', cFile )+1), nModo TO 2
DEFAULT lRetenta TO nModo > 1
Do While .T.
DO CASE; Case nModo == 1
USE (cFile) ALIAS (cAlias) NEW EXCLUSIVE
Case nModo == 2
USE (cFile) ALIAS (cAlias) NEW SHARED
Other
USE (cFile) ALIAS (cAlias) NEW SHARED READONLY
End
If neterr()
If lRetenta .AND. MsgRetryCancel( 'Arquivo ' + cFile + ;
' sendo usado em outra estacao!', 'Alerta')
loop
else
retu .f.
endif
Endif
exit
Enddo
return .T.
Saludos
William Adami
FUNCTION OpenFile( cFile, cAlias, nModo, lRetenta )
DEFAULT cAlias TO Subs( cFile, rAt( '\', cFile )+1), nModo TO 2
DEFAULT lRetenta TO nModo > 1
Do While .T.
DO CASE; Case nModo == 1
USE (cFile) ALIAS (cAlias) NEW EXCLUSIVE
Case nModo == 2
USE (cFile) ALIAS (cAlias) NEW SHARED
Other
USE (cFile) ALIAS (cAlias) NEW SHARED READONLY
End
If neterr()
If lRetenta .AND. MsgRetryCancel( 'Arquivo ' + cFile + ;
' sendo usado em outra estacao!', 'Alerta')
loop
else
retu .f.
endif
Endif
exit
Enddo
return .T.
Saludos
William Adami
Re: PCs en la red
TESTE.prg(136) Error E0030 Syntax error: "syntax error at 'CALIAS'"
TESTE.prg(137) Error E0030 Syntax error: "syntax error at 'LRETENTA'"
Poste o .rc -> RESOURCE "REDE"
abs.
TESTE.prg(137) Error E0030 Syntax error: "syntax error at 'LRETENTA'"
Poste o .rc -> RESOURCE "REDE"
Code: Select all
#include "FiveWin.ch"
Function qualmaq
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" )
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" )
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
// FALTA O .RC deste dialogo William - poste por favor.
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
FUNCTION OpenFile( cFile, cAlias, nModo, lRetenta )
DEFAULT cAlias TO Subs( cFile, rAt( '\', cFile )+1), nModo TO 2 // erro lin 136
DEFAULT lRetenta TO nModo > 1 // erro lin 137
Do While .T.
SYSREFRESH()
DO CASE; Case nModo == 1
USE (cFile) ALIAS (cAlias) NEW EXCLUSIVE
Case nModo == 2
USE (cFile) ALIAS (cAlias) NEW SHARED
Other
USE (cFile) ALIAS (cAlias) NEW SHARED READONLY
End
If neterr()
If lRetenta .AND. MsgRetryCancel( 'Arquivo ' + cFile + ;
' sendo usado em outra estacao!', 'Alerta')
loop
else
retu .f.
endif
Endif
exit
Enddo
return .T.
João Santos - São Paulo - Brasil
-
- Posts: 65
- Joined: Tue Apr 14, 2009 9:26 pm
- Location: Brasil
Re: PCs en la red
coloque o #include "COMMON.CH" no inicio do programa.
O resource rede:
rede DIALOG 23, 24, 421, 172
STYLE 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
FONT 8, "MS Sans Serif"
{
CONTROL "", 101, "TWBrowse", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP, 6, 8, 408, 152
}
William
O resource rede:
rede DIALOG 23, 24, 421, 172
STYLE 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
FONT 8, "MS Sans Serif"
{
CONTROL "", 101, "TWBrowse", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP, 6, 8, 408, 152
}
William
Re: PCs en la red
William, em windows 7, não mostra nada. a ListBox fica vazia.
Abs
Code: Select all
#Include "FiveWin.ch"
#Include "Common.cH"
Function PcRede() //qualmaq
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" )
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" )
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
FUNCTION OpenFile( cFile, cAlias, nModo, lRetenta )
DEFAULT cAlias TO Subs( cFile, rAt( '\', cFile )+1), nModo TO 2 // erro
DEFAULT lRetenta TO nModo > 1 // erro
Do While .T.
SYSREFRESH()
DO CASE; Case nModo == 1
USE (cFile) ALIAS (cAlias) NEW EXCLUSIVE
Case nModo == 2
USE (cFile) ALIAS (cAlias) NEW SHARED
Other
USE (cFile) ALIAS (cAlias) NEW SHARED READONLY
End
If neterr()
If lRetenta .AND. MsgRetryCancel( 'Arquivo ' + cFile + ;
' sendo usado em outra estacao!', 'Alerta')
loop
else
retu .f.
endif
Endif
exit
Enddo
return .T.
/*
O resource rede: pcrede.rc
rede DIALOG 23, 24, 421, 172
STYLE 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
FONT 8, "MS Sans Serif"
{
CONTROL "", 101, "TWBrowse", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP, 6, 8, 408, 152
}
*/
João Santos - São Paulo - Brasil
-
- Posts: 65
- Joined: Tue Apr 14, 2009 9:26 pm
- Location: Brasil
Re: PCs en la red
Olá João, segue nova função, totalmente reformulada. Testei com win7 e funcionou. Se puder testar com win8 avise se funcionou ou nao.
Abraço
William
Abraço
William
Code: Select all
***************************
#Include "FiveWin.ch"
* teste da fun‡Æo para mostrar
* os dispositivos da rede
function main
local gg
gg:=listarede()
if gg[1]
msgalert(oemtoansi("Esta‡Æo: ")+gg[2]+CRLF+"Nome: "+gg[3]+CRLF+"Tipo: "+gg[4] )
else
msgalert(oemtoansi("Nenhum dispositivo selecionado !"))
endif
return nil
**************************************************
* Nome...: ListaRede()
* Fun‡ao.: Listar os dispositivos do grupo
* de trabalho da rede
* Retorno: array[4] .T. ou .F. (selecionou ou nÆo)
* Nome da esta‡Æo
* Nome do dispositivo
* Tipo (disco ou impressora)
* Adaptado por William Adami em 13/11/2014
**************************************************
Function ListaRede
Local ncodigo,cestacao,nquantas,ocoment,odlg2
local vol:={.f.,"","",""},obrw,area:=select(),vldbf,cComando,ob[2]
nquantas :=0
* cria arquivo dbf temporario na memoria
vldbf:= {}
AAdd(vldbf, {"quantas", "n", 4, 0 })
AAdd(vldbf, {"nome_imp", "c", 14, 0})
AAdd(vldbf, {"estacao", "c", 23, 0})
AAdd(vldbf, {"comentario", "c", 30, 0})
select 77
Hb_DbCreateTemp("CARIMP", vldbf)
cComando = "net view > estacao.txt"
myrun(cComando)
* cria arquivo dbf temporario na memoria
vldbf:= {}
AAdd(vldbf, {"texto", "c", 100, 0})
select 78
Hb_DbCreateTemp("CARTES", vldbf)
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")
cComando = "net view "+cestacao+" > estacao1.txt"
myrun(cComando)
* cria arquivo dbf temporario na memoria
vldbf:= {}
AAdd(vldbf, {"texto", "c", 100, 0})
select 79
Hb_DbCreateTemp("CARTIM", vldbf)
APPEND FROM estacao1.txt SDF
dbselectarea("CARTIM")
dbgotop()
Do while !eof()
if substr(CARTIM->texto,27,4)#'Disc'.AND.substr(CARTIM->texto,27,4)#'Impr'
dbskip(1)
loop
else
if substr(CARTIM->texto,27,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')
CARTIM->(DBCLOSEAREA())
dbdrop("MEM:CARTIM")
dbselectarea('CARTES')
dbskip(1)
Enddo
dbselectarea('CARTES')
CARTES->(DBCLOSEAREA())
dbdrop("MEM:CARTES")
if file('ESTACAO.TXT')
ferase('ESTACAO.TXT')
endif
if file ('ESTACAO1.TXT')
ferase('ESTACAO1.TXT')
endif
dbselectarea('CARIMP')
go top
DEFINE DIALOG oDlg2 FROM 5, 2 TO 30, 55 TITLE "LISTA DE DISPOSITIVOS DA REDE"
odlg2:lhelpicon:=.f.
@ 1 , 0.8 LISTBOX obrw VAR cItem ;
FIELDS carimp->NOME_IMP, ;
carimp->ESTACAO, ;
carimp->COMENTARIO ;
HEADERS OemToAnsi( "NOME" ), ;
OemToAnsi( "ESTACAO" ), ;
OemToAnsi( "Tipo" ) ;
OF odlg2 SIZE 200, 140 ;
COLOR CLR_WHITE, CLR_GREEN ;
ON DBLCLICK (vol:={ .t.,rtrim(carimp->estacao), rtrim(carimp->nome_imp),rtrim(carimp->comentario) },odlg2:end())
obrw:bKeyChar := {|nK| if( nK==VK_RETURN,(vol:={ .t., rtrim(carimp->estacao), rtrim(carimp->nome_imp),rtrim(carimp->comentario) },odlg2:end()) ,NIL)}
@ 9, 8 BUTTON ob[1] PROMPT "&Ok" OF oDlg2 SIZE 40, 12 ACTION (vol:={ .t.,rtrim(carimp->estacao), rtrim(carimp->nome_imp),rtrim(carimp->comentario) },odlg2:end())
@ 9, 18 BUTTON ob[2] PROMPT "&Sair" OF oDlg2 SIZE 40, 12 ;
ACTION (oDlg2:End() )
activate dialog odlg2 centered
CARIMP->(DBCLOSEAREA())
dbdrop("MEM:CARIMP")
select(area)
Return vol
FUNCTION myRUN( cComando, nStyle, lWait, lShowResult )
local oShell, RET
IF valtype( nStyle ) != "N"
nStyle := 0
ENDIF
IF ValType( lWait ) != "L"
lWait := .T.
ENDIF
IF ValType( lShowResult ) != "L"
lShowResult := .F.
ENDIF
oShell := CreateObject( "WScript.Shell" )
IF !GetEnv( "OS" ) == "Windows_NT"
cComando += "start " + cComando
ENDIF
TRY
RET := oShell:Run( "%comspec% /c " + cComando, nStyle, lWait )
CATCH
msgstop("ERRO NO ENVIO DO COMANDO !","ERRO")
END
IF lShowResult .AND. RET > 0 .and. RET <= 32
msginfo( "Erro Win_Run(): " + ltrim( Str( RET ) ), " OK " )
ENDIF
oShell := NIL
Return IF( RET = 0, .T., .F. )