dllname "advapi32.dll"
cdeclare long RegOpenKeyEx(long,LPSTR,long,long,long);
cdeclare long RegCloseKey(long);
cdeclare long RegQueryValueEx(int,LPSTR,long,long,LPSTR,long);
const HKEY_CURRENT_USER = &H80000001
const KEY_QUERY_VALUE = &H1
const ERROR_SUCCESS = 0
proc main
	dim k$,kn$,s$,line_beg,line_end
	dim hKey as long
	dim buf_size as long
	dim kbuf$ as string[80]
	if @hwnd = 0 then exit proc
	'レジストリから引用符の設定を取得
	k$ = cformat$("Software\araken\QX\%d\Mode",@@RegistryLoadNum)
	kn$ = "Quote1"
	if RegOpenKeyEx(HKEY_CURRENT_USER,k$,0,KEY_QUERY_VALUE,varptr(hKey)) = \
		ERROR_SUCCESS then
		buf_size = 80
		RegQueryValueEx(hKey,kn$,0,0,kbuf$,varptr(buf_size))
	end if
	RegCloseKey(hKey)
	if kbuf$ = "" then
		call msgbox("引用符の設定を取得できません。",MB_ICONEXCLAMATION)
		exit proc
	end if
	'シフトキーの押下でスペースの有無を変更
	if iskeydown(KEY_SHIFT) then
		if right$(kbuf$,1) = " "then
			kbuf$ = rtrim$(kbuf$)
		else
			kbuf$ = kbuf$+" "
		end if
	end if
	@Redraw = 0:@UndoBlock =1
	if @Select then
		line_beg = @SelectStartLine:line_end = @SelectEndLine
		if @SelectEndBytePosCr > 1 then line_end = line_end+1
		@BlockSelect
		@Line = line_beg
		@MoveBeginningLine
		do while @Line < line_end
			@Insert kbuf$
			@MoveNextLineCr
		loop
	else
		@MoveBeginningLine
		@Insert kbuf$
		@MoveNextLineCr
	end if
	@Redraw = 1:@UndoBlock = 0
end proc |