first commit

master
兔子 6 years ago
commit 1c10d6c89f

@ -0,0 +1,88 @@
package win32api
import (
"errors"
"strconv"
"syscall"
"unsafe"
)
func ShellExecute(hwnd HWND, lpOperation, lpFile, lpParameters, lpDirectory string, nShowCmd int) error {
shell32, err := syscall.LoadLibrary("shell32.dll")
var op, param, directory uintptr
if err != nil {
return errors.New("Can't Load Shell32 API")
}
defer syscall.FreeLibrary(shell32)
ShellExecute, err := syscall.GetProcAddress(syscall.Handle(shell32), "ShellExecuteW")
if err != nil {
return errors.New("Can't Load ShellExecute API")
}
if len(lpOperation) != 0 {
op = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpOperation)))
}
if len(lpParameters) != 0 {
param = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpParameters)))
}
if len(lpDirectory) != 0 {
directory = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpDirectory)))
}
r, _, _ := syscall.Syscall6(uintptr(ShellExecute), 6,
uintptr(hwnd),
op,
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpFile))),
param,
directory,
uintptr(nShowCmd))
if r < 32 {
return errors.New("ERROR:" + strconv.Itoa(int(r)))
}
return nil
}
/**
func ShellExecuteEX2(hwnd HWND, lpVerb, lpFile, lpParameters, lpDirectory string, nShow int) error {
var newcmd SHELLEXECUTEINFOW
newcmd.cbSize = DWORD(unsafe.Sizeof(newcmd))
newcmd.hwnd = hwnd
newcmd.lpVerb = lpVerb
newcmd.lpFile = lpFile
newcmd.lpParameters = lpParameters
newcmd.lpDirectory = lpDirectory
newcmd.nShow = nShow
shell32, err := syscall.LoadLibrary("shell32.dll")
if err != nil {
return errors.New("Can't Load Shell32 API")
}
defer syscall.FreeLibrary(shell32)
ShellExecuteEx, err := syscall.GetProcAddress(syscall.Handle(shell32), "ShellExecuteExW")
if err != nil {
return errors.New("Can't Load ShellExecuteEx API")
}
r, _, _ := syscall.Syscall6(ShellExecuteEx, 1, uintptr(unsafe.Pointer(&newcmd)), 0, 0, 0, 0, 0)
fmt.Println(strconv.Itoa(int(r)))
fmt.Println(strconv.Itoa(int(newcmd.hInstApp)))
if r != 0 {
return errors.New("Error Recured")
}
return nil
}
*/
func ShellExecuteEx(muzika SHELLEXECUTEINFOW) error {
shell32, err := syscall.LoadLibrary("shell32.dll")
if err != nil {
return errors.New("Can't Load Shell32 API")
}
defer syscall.FreeLibrary(shell32)
ShellExecuteEx, err := syscall.GetProcAddress(syscall.Handle(shell32), "ShellExecuteExW")
if err != nil {
return errors.New("Can't Load ShellExecuteEx API")
}
r, _, _ := syscall.Syscall6(ShellExecuteEx, 1, uintptr(unsafe.Pointer(&muzika)), 0, 0, 0, 0, 0)
if r != 0 {
return errors.New("Error Recured")
}
return nil
}

@ -0,0 +1,24 @@
package win32api
type SHELLEXECUTEINFOW struct {
cbSize DWORD
fMask ULONG
hwnd HWND
lpVerb string
lpFile string
lpParameters string
lpDirectory string
nShow int
hInstApp HINSTANCE
lpIDList LPVOID
lpClass string
hkeyClass HKEY
dwHotKey DWORD
union UNION
hProcess HANDLE
}
type UNION struct {
hIcon HANDLE
hMonitor HANDLE
}

@ -0,0 +1,49 @@
package win32api
import "unsafe"
type (
ATOM uint16
BOOL int32
COLORREF uint32
DWM_FRAME_COUNT uint64
DWORD uint32
HACCEL HANDLE
HANDLE uintptr
HBITMAP HANDLE
HBRUSH HANDLE
HCURSOR HANDLE
HDC HANDLE
HDROP HANDLE
HDWP HANDLE
HENHMETAFILE HANDLE
HFONT HANDLE
HGDIOBJ HANDLE
HGLOBAL HANDLE
HGLRC HANDLE
HHOOK HANDLE
HICON HANDLE
HIMAGELIST HANDLE
HINSTANCE HANDLE
HKEY HANDLE
HKL HANDLE
HMENU HANDLE
HMODULE HANDLE
HMONITOR HANDLE
HPEN HANDLE
HRESULT int32
HRGN HANDLE
HRSRC HANDLE
HTHUMBNAIL HANDLE
HWND HANDLE
LPARAM uintptr
LPCVOID unsafe.Pointer
LPVOID unsafe.Pointer
LRESULT uintptr
PVOID unsafe.Pointer
QPC_TIME uint64
ULONG uint32
ULONG_PTR uintptr
WPARAM uintptr
TRACEHANDLE uintptr
)
Loading…
Cancel
Save