Page 1 of 1

allocAtomicHeap

Posted: 19 Aug 2015 16:34
by Tonton Luc
Hi,

This code work fine :

Code: Select all

        Hwnd = gui_native::findwindow("Progman",nullString),         Hwnd2 = gui_native::findwindowex(Hwnd,nullHandle,"SHELLDLL_DefView",nullString),         Listview = gui_native::findwindowex(Hwnd2,nullHandle,"SysListView32",nullString),         Nb = gui_native::sendmessage(Listview,listViewControl::lvm_getItemCount, 0,0),         stdio::write(Nb," desktop icons"),stdio::nl,
but not this one (generate a Windows error) :

Code: Select all

       Text0 = memory::allocAtomicHeap(sizeOfDomain(string)),         TextT = uncheckedConvert(unsigned,Text0),         R_ItemPos = gui_native::sendmessage(Listview,listViewControl::lvm_GetItemText ,1,TextT),         Text = uncheckedConvert(string,TextT),         stdio::write("R_ItemPos = ",R_ItemPos," - Text = ",Text),stdio::nl
I'm not sure about allocAtomicHeap.
Any :idea:

Posted: 19 Aug 2015 20:10
by Thomas Linder Puls
Always include the actual error message.

Anyway, it is quite clear that you have allocated a much too short buffer. To hold a string of length L you should allocate sizeOfDomain(char) * (L+1) bytes:

Code: Select all

Text0 = memory::allocAtomicHeap(sizeOfDomain(char) * (L+1)),

Posted: 24 Aug 2015 6:51
by Tonton Luc
Ok, your code works fine.
Thanks.