Jump to content

Recommended Posts

Posted

The Singleton function is behaving differently between my desktop and my laptop, even in a compiled file. For some reason on the laptop, it returns a handle every time the function is called regardless of whether the $sOccurrenceName value is already used or not.

I took this code and compiled:

#include <Misc.au3>
#include <Debug.au3>

$a = _Singleton('test', 1)
$b = _Singleton('test', 1)

MsgBox(0, '', _DebugBugReportEnv() & @LF & $a & @LF & $ B)

 

When run on my desktop I get this:

AutoIt:3.3.9.4 AdminMode Compiled   (Os:WIN_7/SP1/X64   OSLang:0409)

0x000001DC

0

But on my laptop I get this:

AutoIt:3.3.9.4 AdminMode Compiled   (Os:WIN_7/SP1/X64   OSLang:0409)

0x0000023C

0x00000240

I don't even know where to start with troubleshooting this. Any ideas?

Posted

Did you try with the stable version?

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

No actually I didn't. I've always just overwritten the stable with the beta so I didn't even have it on hand. I just grabbed it though and I do get the same kind of result.

Desktop:

AutoIt:3.3.8.1 AdminMode Compiled   (Os:WIN_7/SP1/X64   OSLang:0409)
0x00000194
0

Laptop:

AutoIt:3.3.8.1 AdminMode Compiled   (Os:WIN_7/SP1/X64   OSLang:0409)
0x00000238
0x0000023C

*Edit: And before anyone asks, compiling as 64 bit changes nothing except that the handle strings are much longer. ie: 0x0000000000000174

Edited by therks
Posted

I believe KaFu has discussed this subject in length at some point or someone has at least. I use _SingletonPID in my signature personally.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Maybe call _WinAPI_GetLastErrorMessage() directly after the _Singleton() call to see what's going wrong. I my case CreateMutexW returned winapi-error 126 - "The specified module could not be found", quite unspecific and I gave up and created an >alternative function.

Posted
  On 6/6/2013 at 10:54 PM, NutStomper said:

Trying running this code and post the output. _MutexExists() is a simplified version of _Singleton().

ConsoleWrite(_MutexExists("TEST") & @CRLF)
ConsoleWrite(_MutexExists("TEST") & @CRLF)
ConsoleWrite(_MutexExists("TEST") & @CRLF)

Func _MutexExists($s_Name)
    DllCall("kernel32.dll", "handle", "CreateMutexW", "ptr", 0, "bool", 1, "wstr", $s_Name)
    Local $a_Ret = DllCall("kernel32.dll", "dword", "GetLastError")
    Return $a_Ret[0] = 183 ; $ERROR_ALREADY_EXISTS
EndFunc

That's basically @error in _Singleton.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

  On 6/6/2013 at 10:05 PM, KaFu said:

Maybe call _WinAPI_GetLastErrorMessage() directly after the _Singleton() call to see what's going wrong. I my case CreateMutexW returned winapi-error 126 - "The specified module could not be found", quite unspecific and I gave up and created an >alternative function.

Looks like I'm getting the same thing. Using an alternative function is not really an issue but I've got a few compiled programs that made use of _Singleton() and I'm now realizing that it just doesn't work everywhere. :(

Edited by therks
Posted

Who to blame though?

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...