Hello guys,

I was experimenting with AsmCtrl and I already can modify him well, but I can't implement get method for BSTR property. I tried several thing but nothing works. Put method is working perfectly. here is my code:



put_Text proc uses __this this_:ptr CUpServClass, newStr:BSTR

mov __this,this_

lea edx,m_szString
mov eax,newStr
.if (eax)
invoke SysStringLen,newStr ; get size of string
.if eax
lea ecx,m_szString
invoke WideCharToMultiByte, CP_ACP, 0, newStr, -1, ecx, eax, NULL, NULL
invoke SysFreeString,newStr
.else
return E_POINTER
.endif
.else
return E_POINTER
.endif
mov m_isDirty, TRUE
return S_OK

put_Text endp

get_Text proc uses __this this_:ptr CUpServClass, pStr:ptr BSTR
LOCAL lpStr:DWORD,dwStrLen:DWORD,lpBStr:DWORD
LOCAL txtBufer[512]:BYTE

mov __this,this_

lea eax,m_szString
mov lpStr,eax ; store offset of our normal string
invoke lstrlen,edx ; get his lenght
mov dwStrLen,eax ; store lenght of string
invoke MultiByteToWideChar,CP_ACP,0,lpStr, -1,addr txtBufer,dwStrLen ; convert string
invoke SysAllocString,addr txtBufer ; allocate BSTR
.if eax
mov edx,pStr
mov [edx],eax ; test code
mov pStr,eax ; test code
mov eax,S_OK
.else
mov eax, E_POINTER
.endif
ret

get_Text endp


If I'm testing get_Text in OCX Container it returns nothing. Can please anybody explain me what I'm doing wrong?

Thanks in advance

frankie
Posted on 2003-05-13 08:16:44 by frankies
Hi frankies,

this looks not good:



lea eax,m_szString
mov lpStr,eax ; store offset of our normal string
invoke lstrlen,edx ; get his lenght ;<----- where is edx set???
mov dwStrLen,eax ; store lenght of string


Japheth
Posted on 2003-05-13 10:32:32 by japheth
Thanks Japheth,

I've must been sleeping :stupid: when I wrote that code. Sorry for posting things which aren't real problems, just lack of mine focus. Well anyway here is finally working code for everybody who will face it in future:



put_Text proc uses __this this_:ptr CUpServClass, newStr:BSTR

mov __this,this_

lea edx,m_szString
mov eax,newStr
.if (eax)
invoke SysStringLen,newStr ; get size of string
.if eax
lea ecx,m_szString
invoke WideCharToMultiByte, CP_ACP, 0, newStr, -1, ecx, eax, NULL, NULL
invoke SysFreeString,newStr
.else
return E_POINTER
.endif
.else
return E_POINTER
.endif
mov m_isDirty, TRUE
return S_OK

put_Text endp

get_Text proc uses __this this_:ptr CUpServClass, pStr:ptr BSTR
LOCAL lpStr:DWORD,dwStrLen:DWORD,lpBStr:DWORD
LOCAL txtBufer[512]:BYTE

mov __this,this_

lea eax,m_szString
mov lpStr,eax ; store offset of our normal string
invoke lstrlen,lpStr ; get his lenght
mov dwStrLen,eax ; store lenght of string
invoke MultiByteToWideChar,CP_ACP,0,lpStr, -1,addr txtBufer,dwStrLen ; convert string
invoke SysAllocStringLen,addr txtBufer,dwStrLen
.if eax
mov edx,pStr
mov [edx],eax
mov eax,S_OK
.else
mov eax, E_POINTER
.endif
ret

get_Text endp


regards

frankie

P.S.: sorry there was still one little error so this is the final version
Posted on 2003-05-13 15:47:47 by frankies