I would like to send a message to Bouyomi-Chan on Windows using interprocess 
communication.

So I wrote the following code.
    
    
    import winim
    
    var cds: ref COPYDATASTRUCT
    cds.dwData = 0
    cds.lpData = ref "Hello World"
    cds.cbData = len(cds.lpData) + 1
    
    # 13436904 is test handle
    let result = SendMessage(HWND(13436904), WM_COPYDATA, 0, LPARAM(cds));
    echo result
    
    
    Run

However, errors occur in `cds.lpData = ref "Hello World"`, `cds.cbData = 
len(cds.lpData) + 1` and `LPARAM(cds)`.
    
    
    cds.lpData = ref "Hello World" ' s error:
    type mismatch: got <type ref Error Type> but expected 'PVOID = pointer'
    
    cds.cbData = len(cds.lpData) + 1' s error:
    ype mismatch: got <PVOID>
    but expected one of:
    proc len(s: mstring): int
    first type mismatch at position: 1
    
    let result = SendMessage(HWND(13436904), WM_COPYDATA, 0, LPARAM(cds));'s 
error:
     type mismatch: got <ref COPYDATASTRUCT> but expected 'LPARAM = int64'
    
    
    Run

How should I match these types? Please let me know if anyone knows.

Thank you.

Reply via email to