Hi, I've tried to convert this code into VB but failed :'(
Now I need help putting this code into a DLL which I can use in my VB app.
I currently do not have a C++ compiler. Can someone put this code into a dll, which will allow me to call the code from my VB app? I'll give a working cd-key of your choice: WC2, WC3, or Starcraft.
Heres the code.
BitFields::BitFields(BYTE *d)
{
m_Data = d;
m_Pos = 0;
}
BitFields::BitFields()
{
m_Pos = 0;
}
DWORD BitFields::GetBitField( DWORD pos, DWORD len)
{
DWORD dBitField = (DWORD)(*(unsigned __int64 *)(m_Data+pos/8)<<(64-len-(pos&7))>>(64-len));
m_sDebugLines.AddTail( PrintBitField( pos, len, dBitField)) ;
return dBitField ;
}
DWORD BitFields::GetField(DWORD len, CString sDebug)
{
m_sDebugComment = sDebug ;
return GetBitField( (m_Pos+=len)-len, len) ;
}
//.h file
class BitFields
{
public:
BYTE* m_Data;
DWORD m_Pos;
CString m_sDebugComment ;
CStringList m_sDebugLines ;
BitFields(BYTE *d) ;
BitFields() ;
DWORD GetBitField( DWORD pos, DWORD len) ;
DWORD GetField( DWORD len, CString sDebug="-") ;
} ;
Thanks.
You can't instantiate exported C++ classes in VB.
Quote from: Yoni on November 10, 2005, 02:32 PM
You can't instantiate exported C++ classes in VB.
What about through COM?
That is not a COM class.
Quote from: Yoni on November 10, 2005, 04:10 PM
That is not a COM class.
I was just speaking generally.
You still don't instantiate the C++ class in VB. You just access a COM interface, and the DLL code instantiates the class, not the VB code.
Quote from: Yoni on November 10, 2005, 02:32 PM
You can't instantiate exported C++ classes in VB.
Just give him a set of wrapper functions...
DWORD __stdcall CreateBitfields()
{
return (DWORD)new Bitfields;
}
void __stdcall DestroyBitfields(DWORD handle)
{
delete (Bitfields*)handle;
}
DWORD __stdcall GetBitField(DWORD handle, DWORD pos, DWORD len)
{
return ((Bitfields*)handle)->GetBitField(pos, len);
}
etc...