I think it must look like this: # For Reference # COPYDATASTRUCT* {.pure.} = object # dwData*: ULONG_PTR # cbData*: DWORD # lpData*: PVOID # https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-copydatastruct # cbData # Type: DWORD # The size, in bytes, of the data pointed to by the lpData member. import winim var mydata: cstring = "Hello World" var cds: COPYDATASTRUCT cds.dwData = 0 cds.lpData = addr mydata # addr gets a pointer to the mydata cstring cds.cbData = mydata.len.DWORD Run
since lpData is a pointer the "size" of the pointer makes no sense here (since it will always be 32/64 bit).