<p>I have imported the <code>kernel32</code> library. So, I have the <code>createMutex</code> function available but I am not quite sure of the various parameters and return values.</p>

<p>This is classic Visual Basic, not Visual Basic.NET but I can probably work with either language in the form of an answer.</p>

[{'answer_id': 1025, 'author': 'Darren Kopp', 'author_id': 77, 'author_profile': 'https://Stackoverflow.com/users/77', 'pm_score': 1, 'selected': False, 'text': '<p>Well, based on the <a href="http://msdn.microsoft.com/en-us/library/ms682411(VS.85).aspx" rel="nofollow noreferrer">documentation</a> it looks like:</p>\n\n<ol>\n<li>Security attributes (can pass null)</li>\n<li>Whether it\'s initially owned (can pass false)</li>\n<li>The name of it</li>\n</ol>\n\n<p>HTH</p>\n'}, {'answer_id': 1028, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 4, 'selected': True, 'text': "<p>The VB code looks something like this:</p>\n\n<pre><code>hMutex = CreateMutex(ByVal 0&amp;, 1, ByVal 0&amp;)\n</code></pre>\n\n<p>The first parameter is a pointer to an <code>SECURITY_ATTRIBUTES</code> structure. If you don't know what it is, you don't need it. Pass NULL (0).</p>\n\n<p>The second parameter is <code>TRUE</code> (non-zero, or 1) if the calling thread should take ownership of the mutex. <code>FALSE</code> otherwise.</p>\n\n<p>The third parameter is the mutex name and may be NULL (0), as shown. If you need a named mutex, pass the name (anything unique) in. Not sure whether the <code>VB</code> wrapper marshals the length-prefixed <code>VB</code> string type (<code>BSTR</code>) over to a null-terminated Ascii/Unicode string if not, you'll need to do that and numerous examples are out there.</p>\n\n<p>Good luck!</p>\n"}, {'answer_id': 82335, 'author': 'MarkJ', 'author_id': 15639, 'author_profile': 'https://Stackoverflow.com/users/15639', 'pm_score': 3, 'selected': False, 'text': '<p>Here\'s the VB6 declarations for <a href="http://msdn.microsoft.com/en-us/library/ms682411(VS.85).aspx" rel="noreferrer">CreateMutex</a> - I just copied them from the API viewer, which you should have as part of your VB6 installation. VB6 marshalls strings to null-terminated ANSI using the current code page.</p>\n\n<pre><code>Public Type SECURITY_ATTRIBUTES\n   nLength As Long\n   lpSecurityDescriptor As Long\n   bInheritHandle As Long \nEnd Type\n\nPublic Declare Function CreateMutex Lib "kernel32" Alias "CreateMutexA" _\n   (lpMutexAttributes As SECURITY_ATTRIBUTES, ByVal bInitialOwner As Long, _\n    ByVal lpName As String) As Long\n</code></pre>\n\n<p>Bear in mind that if you create a mutex from the VB6 IDE, the mutex belongs to the IDE and won\'t be destroyed when you stop running your program - only when you close the IDE.</p>\n'}]
['https://Stackoverflow.com/questions/947', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/243/']