• Welcome to Valhalla Legends Archive.
 

Creating a DLL

Started by teK, November 10, 2005, 02:29 PM

Previous topic - Next topic

teK

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.


Yoni

You can't instantiate exported C++ classes in VB.

MyndFyre

Quote from: Yoni on November 10, 2005, 02:32 PM
You can't instantiate exported C++ classes in VB.

What about through COM?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Yoni

That is not a COM class.

MyndFyre

QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Yoni

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.

Adron

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...