PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 10
 1 
 on: June 12, 2021, 04:10:05 AM 
Started by Petrus Vorster - Last post by philbar
Thanks, Bumblebee, and likewise.

 2 
 on: June 11, 2021, 04:14:04 PM 
Started by Petrus Vorster - Last post by Bumblebee
Wishing everyone in the Northern Hemisphere a happy summer.

 3 
 on: May 27, 2021, 05:15:52 PM 
Started by jermy - Last post by Wilko Verweij
i have it working now, i was trying to find out if a program is running.
I think the recommended way to do this is to take a snapshot: https://docs.microsoft.com/en-us/windows/win32/toolhelp/taking-a-snapshot-and-viewing-processes
I have implemented this in FreeBasic somewhere. If you need it I can dig it up for you.
Wilko

 4 
 on: May 26, 2021, 02:33:32 PM 
Started by jermy - Last post by jermy
i have it working now, i was trying to find out if a program is running.

 5 
 on: May 26, 2021, 07:11:20 AM 
Started by jermy - Last post by Paul Squires
Can you explain what it is you are trying to do? Are you searching for top level windows or top level windows and all of their respective child windows? Are you just trying to see if another application is open and/or active?

 6 
 on: May 26, 2021, 01:10:46 AM 
Started by jermy - Last post by Josť Roca
The return parameter must be LONG, not BOOL, and you must return CTRUE (1) not TRUE (-1).

 7 
 on: May 25, 2021, 07:13:37 PM 
Started by jermy - Last post by jermy
somehow it doesn't work here.
does not matter, we do it differently

Code: [Select]
declare Function EnumHwndProc(Byval hwnd As HWND, Byval lParam As LPARAM) As BOOL

                      EnumChildWindows( hWnd, @EnumHwndProc, 0)   

Function EnumHwndProc(Byval hwnd As HWND, Byval lParam As LPARAM) As BOOL

? hwnd

    Return TRUE '' Continue enumeration.
End Function

 8 
 on: May 23, 2021, 06:18:18 AM 
Started by jermy - Last post by Paul Squires
I had no trouble calling your function to search for a visible window. It never seemed to cause a infinite loop.

Having said that, here is what EnumWindows in the api has to say:

Quote
This function is more reliable than calling the GetWindow function in a loop. An application that calls GetWindow to perform this task risks being caught in an infinite loop or referencing a handle to a window that has been destroyed.

 9 
 on: May 20, 2021, 02:31:22 PM 
Started by jermy - Last post by jermy
How come I get a deadlock if the window is not found?
if the window is found, nothing is wrong

Code: [Select]
' ========================================================================================
' Retrieves the window handle given it's window name
' ========================================================================================
PRIVATE FUNCTION GethWndFromName (BYVAL sName AS cwstr) AS HWND
   DIM nLen AS LONG = Len(sName)
    DIM cwsText AS CWSTR = SPACE(nLen + 1)
 
   ' // Get the first window handle
   DIM hwnd AS HWND = FindWindowW(NULL, NULL)

   ' // Enumerate all the windows
   WHILE hwnd <> NULL
      ' // If the parent window is NULL, it's a top level window
      IF GetParent(hwnd) = NULL THEN
     
         SendMessageW(hwnd, WM_GETTEXT, nLen + 1, cast(LPARAM, *cwsText))
         if sName = cwsText then  ' // We have found it ?
            FUNCTION = hwnd
            EXIT WHILE
         END IF
       
       END IF
      ' // Get the next window handle
       hwnd = GetWindow(hwnd, GW_HWNDNEXT)     
   WEND
END FUNCTION
' ========================================================================================

 10 
 on: May 20, 2021, 07:11:05 AM 
Started by Josť Roca - Last post by Eigil Dingsor
Now it is a matter of seeing if the task can be simplified, if we can use a Free Basic class instead of a plain virtual table, etc.

I'm only interested in low-level COM servers. I don't plan to get involved in the nasty business of creating OCXs, type libraries, etc.

Please note that I'm not using DllMain or LibMain in the DLL because apparently it does not work, so I'm using the constructor and destructor of the module instead.

Very late comment to this post, but I've started to look at Jose's conversion of "COM in plain  C" in conjunction with FB's EXTENDS and OBJECT syntax. Thank you!
It is possible to compile a dll with a Libmain that performs some code at startup. You have to define your own libmain and tell the compiler and linker to use that as the entrypoint function.

example
Code: [Select]
'Using dllmain insted of constructor   code aboce.
'compile with -e switch .Forcing entry function


'/************************** DllMain() **************************
' * Called by the Windows OS when this DLL is loaded or unloaded.
' */

Function  DllMain alias "DLLENTRY"(instance as HINSTANCE ,fdwReason as  DWORD , lpvReserved as LPVOID )  as long

select case fdwReason

case DLL_PROCESS_ATTACH

'// Clear static counts
OutstandingObjects = 0
         LockCount = 0

'// Initialize my IClassFactory with the pointer to its VTable

          MyIClassFactoryObj.lpVtbl = @MyClassFactoryVTbl
'// We don't need to do any thread initialization
DisableThreadLibraryCalls(instance)

end select

return 1
end function

To compile a DLL add this to the build configuration(WinFBE)
-s gui -dll -export -Wl -e_DLLENTRY

Pages: [1] 2 3 ... 10