使い方はほとんど一緒だけど、引数で文字列を使って呼び出すところは、すべて変数を使うように変更してあります。
使い方はほとんど一緒だけど、引数で文字列を使って呼び出すところは、すべて変数を使うように変更してあります。
#include "llmod.as"#include "unicode.as"#module#deffunc replaceNullW val, int, intmref buf, 24mref size, 1mref r, 2sdim _buf, sizememcpy _buf, buf, size, 0, 0sdim buf, size// 4byte NULLだった場合に抜けるj = 0repeatwpeek f1, _buf, cntwpeek f2, _buf, cnt+2peek i, _buf, cntif ((f1 == 0) && (f2 == 0)) : breakif i == r {poke buf, j, 0poke buf, j+1, 0j+=2}else{poke buf, j, ij++}loopreturn#global#moduledummyval = ""dummyvalint = 0#define WM_SETTEXT 0x000C// W is the support Unicode(UTF-16)#deffunc objprmW int, val// Get the first argumentmref p1, 0// Gets the second argumentmref p2, 25// Gets the handle of object_hspobjhandle p1handle = statif handle == 0 : return -1// Gets a pointer to the variablegetptr ptr, p2if ptr == 0 : return -2// Assignment SendMessageW function argumentsprm = handle, WM_SETTEXT, 0, ptr// Call the SendMessageW function of the Win32APIdllproc "SendMessageW", prm, 4, D_USERreturn 0#deffunc titleW val// Get the first argumentmref p1, 24// Gets the window handle;_get_active_window handlemref bmscr, 67handle = bmscr.13if handle == 0 : return -1// Gets a pointer to the variablegetptr ptr, p1if ptr == 0 : return -2// Assignment SendMessageW function argumentsprm = handle, WM_SETTEXT, 0, ptr// Call the SendMessageW function of the Win32APIdllproc "SendMessageW", prm, 4, D_USERreturn 0#define global strlenW(%1 = dummyvalint,%2) _strlenW %1, %2#deffunc _strlenW val, val// Get argumentmref p1, 16mref p2, 25// Gets a pointer to the variablegetptr ptr, p2if ptr == 0 : return -1prm = ptrll_libload msvcrt,"msvcrt"dllproc "wcslen", prm, 1, msvcrtp1 = dllretreturn dllret#deffunc strcatW val, val// Get argumentmref p1, 24mref p2, 25// Gets a pointer to the variablegetptr ptr1, p1getptr ptr2, p2if (ptr1 == 0) || (ptr2 == 0) : return -1prm = ptr1, ptr2ll_libload msvcrt,"msvcrt"dllproc "wcscat", prm, 2, msvcrtreturn 0#define global dialogW(%1 = dummyval,%2=0,%3 = dummyval) _dialogW %1, %3, %2#define MB_OK 0x00000000#define MB_YESNO 0x00000004#define MB_ICONINFORMATION 0x00000040#define MB_ICONEXCLAMATION 0x00000030#define OFN_FILEMUSTEXIST 0x00001000#deffunc _dialogW val, val, int// Gets argumentmref p1, 24mref p2, 25mref p3, 2// Call the original instruction, in the case of color selectionif (p3 == 32) || (p3 == 33) : dialog "", p3 : return// MessageBoxif (p3 == 0) || (p3 == 1) || (p3 == 2) || (p3 == 3){// Gets the window handle;_get_active_window handlemref bmscr, 67handle = bmscr.13if handle == 0 : return -1// Gets a pointer to the variablegetptr ptr1, p1getptr ptr2, p2if p3 == 0 : uType = MB_OK | MB_ICONINFORMATIONif p3 == 1 : uType = MB_OK | MB_ICONEXCLAMATIONif p3 == 2 : uType = MB_YESNO | MB_ICONINFORMATIONif p3 == 3 : uType = MB_YESNO | MB_ICONEXCLAMATION// Assignment MessageBoxW function argumentsprm = handle, ptr1, ptr2, uType// Call the MessageBoxW function of the Win32APIdllproc "MessageBoxW", prm, 4, D_USERreturn dllret}// File selection dialogif (p3 == 16) || (p3 == 17){mref _stat, 64mref _stat, 65// OPENFILENAME structuredim ofn, 22sdim filename, 1024sdim aplFilter, 1024//sdim type, 1024sdim p1c, 1024 // Variable copysdim p2c, 1024 // Variable copymemcpy p1c, p1, 1024, 0, 0memcpy p2c, p2, 1024, 0, 0strlenW ,p1cif stat == 0 {sdim tmptmp = "*.*"to_uni type, tmp, -1sdim tmp2, 1024tmp2 = "All files (*.*)@*.*@"to_uni aplFilter, tmp2, -1; Not work;replaceNullW aplFilter, 1024, '@'size = 1024r = '@'sdim _buf, sizememcpy _buf, aplFilter, size, 0, 0sdim aplFilter, size// If it was NULL(4 bytes) all goes outj = 0repeat size - 4wpeek f1, _buf, cntwpeek f2, _buf, cnt+2peek i, _buf, cntif ((f1 == 0) && (f2 == 0)) : breakif i == r {poke aplFilter, j, 0poke aplFilter, j+1, 0j+=2}else{poke aplFilter, j, ij++}loop;}else{strlenW ,p1cmes "size:"+stattmp = "*."to_uni type, tmp, -1strcatW type, p1c;sdim tmp2, 1024sdim tmp2_u, 1024tmp2 = " ("to_uni tmp2_u, tmp2, -1sdim tmp3, 1024sdim tmp3_u, 1024tmp3 = ")@"to_uni tmp3_u, tmp3, -1sdim tmp4, 1024sdim tmp4_u, 1024tmp4 = "@All files (*.*)@*.*@"to_uni tmp4_u, tmp4, -1strcatW aplFilter, p2cstrcatW aplFilter, tmp2_ustrcatW aplFilter, typestrcatW aplFilter, tmp3_ustrcatW aplFilter, typestrcatW aplFilter, tmp4_u;; Not work;replaceNullW aplFilter, 1024, '@'size = 1024r = '@'sdim _buf, sizememcpy _buf, aplFilter, size, 0, 0sdim aplFilter, size// If it was NULL(4 bytes) all goes outj = 0repeat size - 4wpeek f1, _buf, cntwpeek f2, _buf, cnt+2peek i, _buf, cnt/2*2if ((f1 == 0) && (f2 == 0)) : breakif i == r {poke aplFilter, j, 0//poke aplFilter, j+1, 0j++}else{peek i, _buf, cntpoke aplFilter, j, ij++}loop;}strlenW , typememcpy filename, type, stat * 2, 0, 0//ofn.0 = 88 ; lStructSizeofn.1 = bmscr.13 ; hwndOwnerofn.2 = bmscr.14 ; hInstancegetptr ofn.3, aplFilter ; lpstrFilter;getptr ofn.4, usrFilter ; lpstrCustomFilterofn.5 = 1024 ; nMaxCustFilterofn.6 = 0 ; nFilterIndexgetptr ofn.7, filename ; lpstrFileofn.8 = 1024 ; nMaxFileofn.9 = 0 ; lpstrFileTitleofn.10 = 0 ; nMaxFileTitleofn.11 = 0 ; lpstrInitialDirofn.12 = 0 ; lpstrTitleofn.13 = OFN_FILEMUSTEXIST | 2; Flags// Assignment GetOpenFileNameW function argumentgetptr prm, ofn// Call the GetOpenFileNameW function of the Win32APIif p3 == 16{dllproc "GetOpenFileNameW", prm, 1, D_COMDLG}else : if p3 == 17{dllproc "GetSaveFileNameW", prm, 1, D_COMDLG}if dllret != 0{sdim refstrW@, 1024memcpy refstrW@, filename, 1024, 0, 0}}return dllret#global#module draw#define global printW mesW#define global mesW(%1) draw_init : getptr string_ptr@draw, %1 : _mesW string_ptr@draw#deffunc draw_initstring_ptr = 0return#deffunc _mesWmref bmscr, 67lpRect = csrx, csry, winx, winygetptr lpRect_ptr, lpRectprm = bmscr.4, string_ptr, -1, lpRect_ptr, 0dllproc "DrawTextW", prm, 5, D_USERpos csrx, csry + statreturn#global#module file#define GENERIC_WRITE 0x40000000#define GENERIC_READ 0x80000000#define OPEN_EXISTING 3#define FILE_ATTRIBUTE_NORMAL 0x00000080#define FILE_BEGIN 1#define FILE_CURRENT 1#deffunc init_filefile_u_ptr = 0buf_ptr = 0size = 0offset = 0return#define global bloadW(%1,%2,%3,%4=0) init_file : getptr file_u_ptr@file, %1 : getptr buf_ptr@file, %2 : size@file = %3 : offset@file = %4 : _bloadW 0#define global bsaveW(%1,%2,%3,%4=0) init_file : getptr file_u_ptr@file, %1 : getptr buf_ptr@file, %2 : size@file = %3 : offset@file = %4 : _bloadW 1#define global existW(%1) init_file : getptr file_u_ptr@file, %1 : _bloadW 2#deffunc _bloadW int//, int, int, int/*mref file_u_ptr, 0mref buf_ptr, 1mref size, 2mref offset, 3*/mref mode, 0// Assignment CreateFileW function argumentsif mode == 0{prm = file_u_ptr.0, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0}if mode == 1{prm = file_u_ptr.0, GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0}if mode == 2{prm = file_u_ptr.0, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0}// Call the CreateFileW function of the Win32APIdllproc "CreateFileW", prm, 7, D_KERNELhFile = statif hFile == 0 : return -1if mode == 2{prm = hFile, 0dllproc "GetFileSize", prm, 2, D_KERNELfsize = statprm = hFiledllproc "CloseHandle", prm, 1, D_KERNELstrsizeW@ = fsizereturn fsize}readsize = 0getptr readsize_ptr, readsizeprm = hFile, offset, 0, FILE_BEGINdllproc "SetFilePointer", prm, 4, D_KERNELprm = hFile, buf_ptr, size, readsize_ptr, 0if mode == 0{dllproc "ReadFile", prm, 5, D_KERNEL}else{dllproc "WriteFile", prm, 5, D_KERNEL}prm = hFiledllproc "CloseHandle", prm, 1, D_KERNELstrsizeW@ = readsizereturn readsize#global