<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dataflex.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Paolo.bruno</id>
	<title>DataFlex Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://dataflex.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Paolo.bruno"/>
	<link rel="alternate" type="text/html" href="https://dataflex.wiki/index.php?title=Special:Contributions/Paolo.bruno"/>
	<updated>2026-05-03T02:03:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://dataflex.wiki/index.php?title=Help:Editing&amp;diff=650</id>
		<title>Help:Editing</title>
		<link rel="alternate" type="text/html" href="https://dataflex.wiki/index.php?title=Help:Editing&amp;diff=650"/>
		<updated>2007-10-24T07:14:55Z</updated>

		<summary type="html">&lt;p&gt;Paolo.bruno: New page: * You can find general editing help on [http://www.mediawiki.org/wiki/Help:Editing help on editing from wikimedia] where also a link is included for formatting syntax and within that also ...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* You can find general editing help on [http://www.mediawiki.org/wiki/Help:Editing help on editing from wikimedia] where also a link is included for formatting syntax and within that also help on using HTML, links and tables.&lt;/div&gt;</summary>
		<author><name>Paolo.bruno</name></author>
	</entry>
	<entry>
		<id>https://dataflex.wiki/index.php?title=Run_only_one_instance_of_your_application&amp;diff=649</id>
		<title>Run only one instance of your application</title>
		<link rel="alternate" type="text/html" href="https://dataflex.wiki/index.php?title=Run_only_one_instance_of_your_application&amp;diff=649"/>
		<updated>2007-10-24T07:01:22Z</updated>

		<summary type="html">&lt;p&gt;Paolo.bruno: /* Using mutexes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The question on how to make sure that your application is only started once by your users can be approached in several ways.&lt;br /&gt;
&lt;br /&gt;
1. Using mutexes&lt;br /&gt;
2. Using FindWindow WinAPI&lt;br /&gt;
&lt;br /&gt;
=== Using mutexes ===&lt;br /&gt;
Dalton Pulsipher says:&lt;br /&gt;
&amp;quot;We use a MuteX object to do this.  Just attach one to your program and on &lt;br /&gt;
startup check if it already exists on the system.  &lt;br /&gt;
Here is the code if you want to go that route.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In the SRC file within the panel object put this piece of code:&lt;br /&gt;
 Procedure Exit_Application&lt;br /&gt;
    integer iVoid&lt;br /&gt;
    If (ghMuteX) Move (CloseHandle(ghMutex)) to iVoid&lt;br /&gt;
    move 0 to ghMuteX&lt;br /&gt;
    Forward Send Exit_Application&lt;br /&gt;
 End_Procedure&lt;br /&gt;
And in a package that gets hit on startup:&lt;br /&gt;
 // Constants&lt;br /&gt;
 Define ERROR_INVALID_HANDLE        for 6    //  taken from error.h of VS7&lt;br /&gt;
 Define ERROR_ALREADY_EXISTS        for 183&amp;lt;br/&amp;gt;&lt;br /&gt;
 Handle ghMuteX&amp;lt;br/&amp;gt;&lt;br /&gt;
 // external functions&lt;br /&gt;
 #IFNDEF Get_CreateMuteX&lt;br /&gt;
     External_Function CreateMuteX &amp;quot;CreateMutexA&amp;quot; Kernel32.dll Integer i1 Integer i2 Integer i3 Returns Integer&lt;br /&gt;
 #ENDIF&lt;br /&gt;
 #IFNDEF Get_CloseHandle&lt;br /&gt;
    External_Function CloseHandle &amp;quot;CloseHandle&amp;quot; Kernel32.dll Integer i1 Returns Integer&lt;br /&gt;
 #ENDIF&amp;lt;br/&amp;gt;&lt;br /&gt;
 // function to create a mutex&lt;br /&gt;
 Procedure Create_MuteX_Object&lt;br /&gt;
    Integer iVoid iErr&lt;br /&gt;
    String sID&lt;br /&gt;
    Move &amp;quot;Unique String For My Application&amp;quot; To sID&lt;br /&gt;
    Move (CreateMuteX(0,1,AddressOf(sID))) To ghMuteX&lt;br /&gt;
    If (ghMuteX &amp;lt;&amp;gt; ERROR_INVALID_HANDLE) Begin&lt;br /&gt;
        Move (GetLastError()) To iErr&lt;br /&gt;
        If (iErr = ERROR_ALREADY_EXISTS) Begin  // program is already &lt;br /&gt;
                                                // running&lt;br /&gt;
            Move (CloseHandle(ghMuteX)) To iVoid&lt;br /&gt;
            Move 0 To ghMuteX&lt;br /&gt;
            // kill the application here if you do not want to allow &lt;br /&gt;
            // multiple instances&lt;br /&gt;
            ABORT&lt;br /&gt;
        End&lt;br /&gt;
        Else Send None  // program is not already running&lt;br /&gt;
    End&lt;br /&gt;
    Else Send None  // rare error; object could not be created&lt;br /&gt;
 End_Procedure  // Create_MuteX_Object&amp;lt;br/&amp;gt;&lt;br /&gt;
 // create the mutex&lt;br /&gt;
 Send Create_MuteX_Object&lt;br /&gt;
&lt;br /&gt;
=== Using FindWindow WinAPI ===&lt;br /&gt;
&lt;br /&gt;
Leslie Brennan says:&lt;br /&gt;
&lt;br /&gt;
Usage in SRC:&lt;br /&gt;
&lt;br /&gt;
 Use myPanel,pkg&lt;br /&gt;
 Object Main is a myPanel&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Source myPanel.pkg&lt;br /&gt;
 ////////////////////////////////////////////&lt;br /&gt;
 //&lt;br /&gt;
 // 05/24/2007 &lt;br /&gt;
 // Panel Class from Pieter van Dieren to check&lt;br /&gt;
 // to make sure program is only run one time.&lt;br /&gt;
 //&lt;br /&gt;
 /////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
 Use dfPanel.pkg&lt;br /&gt;
&lt;br /&gt;
 Class myPanel is a Panel&lt;br /&gt;
    // DoCheckProgramActive&lt;br /&gt;
    // Checks if the program already is active.&lt;br /&gt;
    // If so, it activates the running application and closes this one.&lt;br /&gt;
      Procedure DoCheckProgramActive&lt;br /&gt;
        String sTitle&lt;br /&gt;
        Handle hWnd&lt;br /&gt;
        Integer iVoid&lt;br /&gt;
&lt;br /&gt;
        Register_Object Main&lt;br /&gt;
        Get Label of Main to sTitle&lt;br /&gt;
        Move (FindWindow(&amp;quot;&amp;quot;,sTitle))  to hWnd&lt;br /&gt;
        If (hWnd) Begin&lt;br /&gt;
          Send Stop_Box (sTitle + &amp;quot; Already is Running and Can only be Started Once.&amp;quot;) &amp;quot;Error:&amp;quot;&lt;br /&gt;
          Move (ShowWindow(hWnd,SW_MAXIMIZE)) to iVoid  // 9 =SW_RESTORE SW_NORMAL&lt;br /&gt;
          Move (SetForegroundWindow(hWnd)) to iVoid&lt;br /&gt;
          Abort&lt;br /&gt;
        End&lt;br /&gt;
      End_Procedure // DoCheckProgramActive&lt;br /&gt;
&lt;br /&gt;
      // End_Construct_Object&lt;br /&gt;
      Procedure End_Construct_Object&lt;br /&gt;
        Send DoCheckProgramActive&lt;br /&gt;
        Forward Send End_Construct_Object&lt;br /&gt;
      End_Procedure // End_Construct_Object&lt;br /&gt;
 End_class&lt;br /&gt;
&lt;br /&gt;
The FindWindow technique is also discussed in the book [http://www.starzen.com/Products/DataFlexVDF/Books/tabid/56/Default.aspx Mastering Visual DataFlex] from Starzen.&lt;/div&gt;</summary>
		<author><name>Paolo.bruno</name></author>
	</entry>
	<entry>
		<id>https://dataflex.wiki/index.php?title=Run_only_one_instance_of_your_application&amp;diff=644</id>
		<title>Run only one instance of your application</title>
		<link rel="alternate" type="text/html" href="https://dataflex.wiki/index.php?title=Run_only_one_instance_of_your_application&amp;diff=644"/>
		<updated>2007-10-23T15:08:29Z</updated>

		<summary type="html">&lt;p&gt;Paolo.bruno: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The question on how to make sure that your application is only started once by your users can be approached in several ways.&lt;br /&gt;
&lt;br /&gt;
1. Using mutexes&lt;br /&gt;
2. Using FindWindow WinAPI&lt;br /&gt;
&lt;br /&gt;
=== Using mutexes ===&lt;br /&gt;
Dalton Pulsipher says:&lt;br /&gt;
&amp;quot;We use a MuteX object to do this.  Just attach one to your program and on &lt;br /&gt;
startup check if it already exists on the system.  &lt;br /&gt;
Here is the code if you want to go that route.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In the SRC file within the panel Object put this piece of code:&lt;br /&gt;
 Procedure Exit_Application&lt;br /&gt;
    integer iVoid&lt;br /&gt;
    If (ghMuteX) Move (CloseHandle(ghMutex)) to iVoid&lt;br /&gt;
    move 0 to iVoid&lt;br /&gt;
    Forward Send Exit_Application&lt;br /&gt;
 End_Procedure&lt;br /&gt;
And in a package that gets hit on startup:&lt;br /&gt;
 // Constants&lt;br /&gt;
 Define ERROR_INVALID_HANDLE        for 6    //  taken from error.h of VS7&lt;br /&gt;
 Define ERROR_ALREADY_EXISTS        for 183&lt;br /&gt;
 //&lt;br /&gt;
 Handle ghMuteX&lt;br /&gt;
 // external functions&lt;br /&gt;
 #IFNDEF Get_CreateMuteX&lt;br /&gt;
     External_Function CreateMuteX &amp;quot;CreateMutexA&amp;quot; Kernel32.dll Integer i1 Integer i2 Integer i3 Returns Integer&lt;br /&gt;
 #ENDIF&lt;br /&gt;
 #IFNDEF Get_CloseHandle&lt;br /&gt;
    External_Function CloseHandle &amp;quot;CloseHandle&amp;quot; Kernel32.dll Integer i1 Returns Integer&lt;br /&gt;
 #ENDIF&lt;br /&gt;
 // function to create a mutex&lt;br /&gt;
 Procedure Create_MuteX_Object&lt;br /&gt;
    Integer iVoid iErr&lt;br /&gt;
    String sID&lt;br /&gt;
    Move &amp;quot;Unique String For My Application&amp;quot; To sID&lt;br /&gt;
    Move (CreateMuteX(0,1,AddressOf(sID))) To ghMuteX&lt;br /&gt;
    If (ghMuteX &amp;lt;&amp;gt; ERROR_INVALID_HANDLE) Begin&lt;br /&gt;
        Move (GetLastError()) To iErr&lt;br /&gt;
        If (iErr = ERROR_ALREADY_EXISTS) Begin  // program is already &lt;br /&gt;
                                                // running&lt;br /&gt;
            Move (CloseHandle(ghMuteX)) To iVoid&lt;br /&gt;
            Move 0 To ghMuteX&lt;br /&gt;
            // kill the application here if you do not want to allow &lt;br /&gt;
            // multiple instances&lt;br /&gt;
            ABORT&lt;br /&gt;
        End&lt;br /&gt;
        Else Send None  // program is not already running&lt;br /&gt;
    End&lt;br /&gt;
    Else Send None  // rare error; object could not be created&lt;br /&gt;
 End_Procedure  // Create_MuteX_Object&lt;br /&gt;
 // create the mutex&lt;br /&gt;
 Send Create_MuteX_Object&lt;br /&gt;
=== Using FindWindow WinAPI ===&lt;br /&gt;
&lt;br /&gt;
Leslie Brennan says:&lt;br /&gt;
&lt;br /&gt;
Usage in SRC:&lt;br /&gt;
&lt;br /&gt;
 Use myPanel,pkg&lt;br /&gt;
 Object Main is a myPanel&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Source myPanel.pkg&lt;br /&gt;
 ////////////////////////////////////////////&lt;br /&gt;
 //&lt;br /&gt;
 // 05/24/2007 &lt;br /&gt;
 // Panel Class from Pieter van Dieren to check&lt;br /&gt;
 // to make sure program is only run one time.&lt;br /&gt;
 //&lt;br /&gt;
 /////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
 Use dfPanel.pkg&lt;br /&gt;
&lt;br /&gt;
 Class myPanel is a Panel&lt;br /&gt;
    // DoCheckProgramActive&lt;br /&gt;
    // Checks if the program already is active.&lt;br /&gt;
    // If so, it activates the running application and closes this one.&lt;br /&gt;
      Procedure DoCheckProgramActive&lt;br /&gt;
        String sTitle&lt;br /&gt;
        Handle hWnd&lt;br /&gt;
        Integer iVoid&lt;br /&gt;
&lt;br /&gt;
        Register_Object Main&lt;br /&gt;
        Get Label of Main to sTitle&lt;br /&gt;
        Move (FindWindow(&amp;quot;&amp;quot;,sTitle))  to hWnd&lt;br /&gt;
        If (hWnd) Begin&lt;br /&gt;
          Send Stop_Box (sTitle + &amp;quot; Already is Running and Can only be Started Once.&amp;quot;) &amp;quot;Error:&amp;quot;&lt;br /&gt;
          Move (ShowWindow(hWnd,SW_MAXIMIZE)) to iVoid  // 9 =SW_RESTORE SW_NORMAL&lt;br /&gt;
          Move (SetForegroundWindow(hWnd)) to iVoid&lt;br /&gt;
          Abort&lt;br /&gt;
        End&lt;br /&gt;
      End_Procedure // DoCheckProgramActive&lt;br /&gt;
&lt;br /&gt;
      // End_Construct_Object&lt;br /&gt;
      Procedure End_Construct_Object&lt;br /&gt;
        Send DoCheckProgramActive&lt;br /&gt;
        Forward Send End_Construct_Object&lt;br /&gt;
      End_Procedure // End_Construct_Object&lt;br /&gt;
 End_class&lt;br /&gt;
&lt;br /&gt;
The FindWindow technique is also discussed in the book [http://www.starzen.com/Products/DataFlexVDF/Books/tabid/56/Default.aspx Mastering Visual DataFlex] from Starzen.&lt;/div&gt;</summary>
		<author><name>Paolo.bruno</name></author>
	</entry>
</feed>