CreateMutex is a wrapper for CreateMutexW WIN32 API function https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createmutexw
(name string)
| 148 | // CreateMutex is a wrapper for CreateMutexW WIN32 API function |
| 149 | // https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createmutexw |
| 150 | func CreateMutex(name string) (uintptr, error) { |
| 151 | ret, _, err := procCreateMutex.Call( |
| 152 | 0, |
| 153 | 0, |
| 154 | uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(name))), |
| 155 | ) |
| 156 | switch int(err.(syscall.Errno)) { |
| 157 | case 0: |
| 158 | return ret, nil |
| 159 | default: |
| 160 | return ret, err |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | // VirtualProtect is a wrapper for the same WIN32 API function |
| 165 | // https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualprotect |