Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


"System.Byte[]" cannot be converted to "System.IConvertible" #39

maul-esel opened this Issue · 0 comments

1 participant



I tried to run the following script with IronAHK

; ============= config =============
IronAHK := true ; set to true if you're using IronAHK.
;  =================================

ptr_size := A_PtrSize ? A_PtrSize : 4 ; ensure AutoHotkey classic / IronAHK compatibility
ptr := A_PtrSize ? "UPtr" : "UInt"

MB_ABORTRETRYIGNORE := 0x00000002 ; define flags
MB_USERICON := 0x00000080
flags := MB_ABORTRETRYIGNORE | MB_USERICON ; set the button we will use + indicate we will provide a custom icon

text := "This box is produced with a DllCall() to the MessageBoxIndirect function, passing a MSGBOXPARAMS structure.`n`n"
        . "This allows you to set a custom icon and more." ; set the text that will be shown
caption := "ahkbook example" ; set the title that will be used

hModule := DllCall("GetModuleHandle") ; get a handle to the running AutoHotkey.exe: we will use an icon from inside it
icon := IronAHK ? 32512 : 159 ; choose the icon id to use (IronAHK has a different one)

struct_size := 4*3 + ptr_size*7 ; calculate struct size:
; cbSize, dwStyle and dwLanguageId are 4 bytes, others depend on system pointer size

VarSetCapacity(params, struct_size, 0) ; initialize structure

; filling in structure members we need:
NumPut(struct_size, params, 00+0*ptr_size,  "UInt") ; "The structure size, in bytes."
NumPut(hModule,     params, 04+1*ptr_size,  ptr) ; "A handle to the module that contains the icon resource identified by the lpszIcon member... "
NumPut(&text,       params, 04+2*ptr_size,  ptr) ; "A null-terminated string that contains the message to be displayed."
NumPut(&caption,    params, 04+3*ptr_size,  ptr) ; "A null-terminated string that contains the message box title."
NumPut(flags,       params, 04+4*ptr_size,  "UInt") ; "The contents and behavior of the dialog box."
NumPut(icon,        params, 08+4*ptr_size,  "UPtr") ; "Identifies an icon resource."

; call the function and pass a pointer to the structure:
DllCall("MessageBoxIndirect", ptr, &params)

This gives the following error:

Could not execute: Das Objekt des Typs "System.Byte[]" kann nicht in Typ "System.IConvertible" umgewandelt werden.
(the object of type "System.Byte[]" cannot be converted to type "System.IConvertible".)

It works fine for AutoHotkey classic, AutoHotkey_L and AutoHotkey v2.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.