I wrote and compiled these 3 programs to see if any act differently, and was surprised to see the one that opened the dll, the .exe file was twice as large as the code importing kernel32.lib, and the code using the API. I thought it's .exe would be smaller, since it used a dll. There seems to be no other than that, that I can tell. I guess my question is, which is the best way, if there is a best way?
This .exe was 8704 bytes in size
Code: Select all
EnableExplicit
Global dll_kernel32 = OpenLibrary(#PB_Any, "kernel32.dll")
Procedure Proc1()
Protected snapShot.i
Protected Proc32.PROCESSENTRY32
If dll_kernel32
snapShot = CallFunction(dll_kernel32, "CreateToolhelp32Snapshot", #TH32CS_SNAPPROCESS, 0)
If snapShot
Proc32\dwSize = SizeOf(PROCESSENTRY32)
If CallFunction(dll_kernel32, "Process32First", snapShot, @Proc32)
While CallFunction(dll_kernel32, "Process32Next", snapShot, @Proc32)
Debug Str(PeekI(@Proc32\th32ProcessID)) + " " + PeekS(@Proc32\szExeFile)
Wend
EndIf
CloseHandle_(snapShot)
EndIf
EndIf
EndProcedure
Proc1()
Delay(2000)
Proc1()
CloseLibrary(dll_kernel32)Code: Select all
EnableExplicit
Import "kernel32.lib"
CreateToolhelp32Snapshot(var1.i, var2.i)
Process32First(var1.i, var2.i)
Process32Next(var1.i, var2.i)
EndImport
Procedure Proc1()
Protected snapShot.i
Protected Proc32.PROCESSENTRY32
Proc32\dwSize = SizeOf(PROCESSENTRY32)
snapShot = CreateToolhelp32Snapshot(#TH32CS_SNAPPROCESS, 0)
If snapShot
If Process32First(snapShot, @Proc32)
While Process32Next(snapShot, @Proc32)
Debug Str(PeekI(@Proc32\th32ProcessID)) + " " + PeekS(@Proc32\szExeFile)
Wend
EndIf
CloseHandle_(snapShot)
EndIf
EndProcedure
Proc1()
Delay(2000)
Proc1()Code: Select all
EnableExplicit
Procedure Proc1()
Protected snapShot.i
Protected Proc32.PROCESSENTRY32
Proc32\dwSize = SizeOf(PROCESSENTRY32)
snapShot = CreateToolhelp32Snapshot_(#TH32CS_SNAPPROCESS, 0)
If snapShot
If Process32First_(snapShot, @Proc32)
While Process32Next_(snapShot, @Proc32)
Debug Str(PeekI(@Proc32\th32ProcessID)) + " " + PeekS(@Proc32\szExeFile)
Wend
EndIf
CloseHandle_(snapShot)
EndIf
EndProcedure
Proc1()
Delay(2000)
Proc1()


