9 de junio de 2003

Listar Las Dlls Cargadas por Nuestro Programa

Este codigo nos permitira mostrar las dll's que han sido cargadas por nuestro programa, ya sea directa o indirectamente, por ejemplo si declaramos una funcion contenida en una Dll esta dll sera cargada por nuestro programa
Public oForm
oForm=Newobject("Lst_Dep")
oForm.Show
Return

Define Class Lst_Dep As Form
 Autocenter = .t.
 Height = 204
 Width = 702
 DoCreate = .T.
 Caption = "Dependecias"
 Name = "Frm_Lst_Dep"

 Add Object command1 As CommandButton With ;
  Top = 173, ;
  Left = 554, ;
  Height = 27, ;
  Width = 144, ;
  Caption = "Listar Dependencias", ;
  Name = "Command1"
 Add Object list1 As ListBox With ;
  ColumnCount = 2, ;
  ColumnWidths = "120,510", ;
  RowSourceType = 1, ;
  RowSource = "", ;
  FirstElement = 1, ;
  Height = 169, ;
  Left = 0, ;
  NumberOfElements = 0, ;
  Top = 1, ;
  Width = 696, ;
  Name = "List1"

 Procedure num2dword
  Lparameter tnNum
  Local c0,c1,c2,c3
  lcresult = Chr(0)+Chr(0)+Chr(0)+Chr(0)
  If tnNum < (2^31 - 1) then
   c3 = Chr(Int(tnNum/(256^3)))
   tnNum = Mod(tnNum,256^3)
   c2 = Chr(Int(tnNum/(256^2)))
   tnNum = Mod(tnNum,256^2)
   c1 = Chr(Int(tnNum/256))
   c0 = Chr(Mod(tnNum,256))
   lcresult = c0+c1+c2+c3
  Endif
  Return lcresult
 Endproc
 Procedure Load
  Declare Long GetCurrentProcessId In "kernel32"
  Declare Long CreateToolhelp32Snapshot In "kernel32" Long lFlags, Long lProcessID
  Declare Long Module32First In "kernel32" Long hSnapshot, String @cProc
  Declare Long Module32Next In "kernel32" Long hSnapshot, String @cProc
 Endproc
 Procedure command1.Click
  Local cProc As String, nLogico As Long, cCadena As String
  cProc =Space(549)
  lProcessID = GetCurrentProcessId()
  hSnapshot = CreateToolhelp32Snapshot(8, 0)
  With Thisform
   .LockScreen = .t. 
   .list1.Clear()
   cProc = .num2dword(548)+.num2dword(0)+.num2dword(0)+;
    +.num2dword(0)+.num2dword(0)+.num2dword(0)+.num2dword(0)+;
    +.num2dword(0)+Space(256)+Space(260)
   nLogico = Module32First(hSnapshot, @cProc)
   cCadena =Space(255)
   nCiclo =0
   Do While nLogico <>0
    nCiclo = nCiclo +1
    cCadena=Substr(cProc,33,255)
    .list1.AddListItem(Substr(cCadena,1,At(Chr(0),cCadena)-1),nCiclo,1)
    cCadena=Substr(cProc,290,259)
    .list1.AddListItem(Substr(cCadena,1,At(Chr(0),cCadena)-1),nCiclo,2)
    nLogico = Module32Next(hSnapshot, @cProc)
   Enddo
   .Caption = "Total Encontrados: " +Alltrim(Str(nCiclo))
   .LockScreen = .F. 
  Endwith
 Endproc
Enddefine
Saludos

Jorge Mota, Guatemala

No hay comentarios. :

Publicar un comentario

Los comentarios son moderados, por lo que pueden demorar varias horas para su publicación.