#include once "window9.bi"

Function GetTextItemListView(ByVal gadget As long, ByVal Item As long, ByVal SubItem_ As Long) As USTRING Export	
	Dim LV As LVITEM
	LV.iSubItem=CInt(SubItem_)
	LV.cchTextMax=256
	#ifdef UNICODE
		Dim sRet As USTRING = wspace(256)
		LV.pszText= cast(any ptr , *sRet)	
		If GetClassName_(GadgetID(gadget)) = "ExplorerGadget" Then
			SendMessage(GetProp(GadgetID(gadget),"EXPLORERGADGETLISTVIEWWINDOW"),LVM_GETITEMTEXTW,CInt(Item),Cast(lparam,@LV))
		Else
			SendMessage(GadgetID(gadget),LVM_GETITEMTEXTW,CInt(Item),Cast(lparam,@LV))
		EndIf				
	#else	
		Dim sRet As USTRING*256
		LV.pszText= Cast(LPSTR,@sRet)		
		If GetClassName_(GadgetID(gadget)) = "ExplorerGadget" Then
			SendMessage(GetProp(GadgetID(gadget),"EXPLORERGADGETLISTVIEWWINDOW"),LVM_GETITEMTEXTA,CInt(Item),Cast(lparam,@LV))
		Else
			SendMessage(GadgetID(gadget),LVM_GETITEMTEXTA,CInt(Item),Cast(lparam,@LV))
		EndIf
	#EndIf
	Return sRet
End Function
