allocAtomicHeap

Discussions related to Visual Prolog
User avatar
Tonton Luc
VIP Member
Posts: 501
Joined: 16 Oct 2001 23:01

allocAtomicHeap

Unread post by Tonton Luc » 19 Aug 2015 16:34

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:

User avatar
Thomas Linder Puls
VIP Member
Posts: 1622
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 19 Aug 2015 20:10

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)),
Regards Thomas Linder Puls
PDC

User avatar
Tonton Luc
VIP Member
Posts: 501
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 24 Aug 2015 6:51

Ok, your code works fine.
Thanks.

Post Reply