-
Notifications
You must be signed in to change notification settings - Fork 0
/
playSound.hsp
93 lines (76 loc) · 1.88 KB
/
playSound.hsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
引数の音を再生する
playSound
【概要】
引数の音を再生する
【作成】
natade-jp
https://github.com/natade-jp
【参考】
コマンドライン引数をUnicode(UTF-16)で受け取る
https://www.natade.net/lang/hsp/contents/sample_unicodecmdline.hsp
*/
#packopt type 1
#packopt name "playSound"
#packopt hide 1
#include "user32.as"
#include "gdi32.as"
#include "kernel32.as"
#include "shell32.as"
#module
#deffunc getUnicodeSize int ptr, local x, local size, local num
size = 0
repeat
dupptr x, ptr + cnt * 2, 4, vartype("int")
num = x & 0xffff
if(num == 0) {
break
}
size += 2
loop
return(size)
#deffunc getUnicodeText int ptr,var text
getUnicodeSize ptr
dupptr text, ptr, stat, vartype("str")
return
#deffunc printUnicode var text,local rect,local BMSCR
dim rect,4
lstrlenW varptr(text)
GetTextExtentPoint32W hdc, varptr(text), stat, varptr(rect)
mref BMSCR,96 + ginfo(3)
BMSCR(68) = rect(0)
BMSCR(69) = rect(1)
rect = ginfo(22), ginfo(23), ginfo(22) + ginfo(14), ginfo(23) + ginfo(15)
DrawTextW hdc, varptr(text), -1, varptr(rect), 0
redraw (BMSCR(19)!=1), ginfo(22), ginfo(23), ginfo(14), ginfo(15)
pos ginfo(22), ginfo(23) + ginfo(15)
return
#deffunc printUnicodePtr int ptr,local text
getUnicodeText ptr, text
printUnicode text
return
#deffunc initCommandLineArgs onexit
if(argsptrptr == 0) {
LocalFree argsptrptr
}
return
#deffunc getCommandLineArgs array argsptr,local pNumArgs
initCommandLineArgs
GetCommandLineW
pNumArgs = 0
CommandLineToArgvW stat, varptr(pNumArgs)
argsptrptr = stat
dupptr argsptr, argsptrptr, 4 * pNumArgs, vartype("int")
return
#global
getCommandLineArgs argsptr
getUnicodeText argsptr(1), text
file = cnvwtos(text)
exist file
if(strsize == -1) {
dialog "[" + file + "]", 1, "ファイルが見つかりません。"
end
}
mmload file, 0, 2
mmplay 0
end