Visual C++ DLL in Visual Basic

Visual C++ DLL in Visual Basic

Post by Keith G. Murph » Wed, 20 Aug 1997 04:00:00



Do you have source for this library?

Let us see the function declaration and what you want to change
it to do, and I suspect any number of people could answer your
question...  Just need more detail, generally...



Quote:> We are having trouble creating a DLL in Visual C++
> that can be used in Visual Basic.  What we are trying
> to do is modify the UNIX RFC DES Password
> Encryption routines for our own internal use.  We've
> found a library on the internet already that works, but
> the function it came with only accepts one paramater,
> we need to pass two, and for the life of me I can't figure
> out what I'm doing wrong, and why I can only pass
> one parameter.

> I've searched Microsoft and MSDN up and down.  Could
> someone point me to some information regarding creating
> DLL's for VB in C++?

> Thanks!
> Bryan Murphy

> ps. Please reply via e-mail if you can!

 
 
 

Visual C++ DLL in Visual Basic

Post by Bryan Murph » Wed, 20 Aug 1997 04:00:00


We are having trouble creating a DLL in Visual C++
that can be used in Visual Basic.  What we are trying
to do is modify the UNIX RFC DES Password
Encryption routines for our own internal use.  We've
found a library on the internet already that works, but
the function it came with only accepts one paramater,
we need to pass two, and for the life of me I can't figure
out what I'm doing wrong, and why I can only pass
one parameter.

I've searched Microsoft and MSDN up and down.  Could
someone point me to some information regarding creating
DLL's for VB in C++?

Thanks!
Bryan Murphy

ps. Please reply via e-mail if you can!

 
 
 

Visual C++ DLL in Visual Basic

Post by Protected Smit » Fri, 22 Aug 1997 04:00:00


How To Write a C++ DLL for Visual Basic
by Mike McKee

You can pull this off easily in 13 steps:

        Assume you have VB 4/32 and VC++ 4.0.
        Assume you can write an ANSI C function, bare minimum.

Launch VC++ Developer Studio.
Choose File, New... and choose Project Workspace.
Choose DLL option and type in the name of your DLL under 8 chars, as in
"netfs."  Assume here for the rest of these instructions that x is your
project name.
Choose Insert Files into Project, Source Files type.  Type a name like
x.cpp
Save the file before you start typing text into it.
Type into x.cpp your C functions with no regard to whether this is a DLL or
not.
Do not type in a Main, DllMain, or any other "main" type function--a DLL
should just contain functions.
Now for the fun stuff.  Preface your C code at the top with:

#define CCONV __stdcall /* NOTE: __stdcall is two underscores, not one
underscore!!! */
#define NOMANGLE

And do the following conversion on each function:

Before
LONG GrantDir (LPSTR lpszDomain, LPSTR lpszAccount, LPSTR lpszDir) {

After
NOMANGLE LONG CCONV GrantDir (LPSTR lpszDomain, LPSTR lpszAccount, LPSTR
lpszDir) {

Choose Insert Files into Project, Definition Files type.  Type a name like
x.def.
Save the file before you start typing text into it.
In x.def file, you must assign a definition for your project.  You might
have to change some things, but generally it should look like:

LIBRARY x
DESCRIPTION 'x can be called from Visual Basic'

CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE

EXPORTS

Note that the library name should be the same name as we've been using for
x all along here.  Also note that the EXPORTS command requires a listing of
functions you had in your x.cpp file.  Each function should be suffixed

From the Build menu, choose Build menuitem to create x.dll.  It's that
easy.

Now an explanation of the trick that made this all easy.  Normally, making
DLLs is a very hard process, involving a DllMain, and some other odd calls,
but when you chose New, Project Workspace, DLL, a header file is attached
to your project that does all the magic to make this a DLL.

 
 
 

Visual C++ DLL in Visual Basic

Post by the frisby » Fri, 22 Aug 1997 04:00:00


Why not try using the Windows cryptography functions, I followed some
example code, and created a .DLL to implement RC4 encryption and
decryption.  This is easily callable by VB programs.  Look on Microsoft
site for reference to wincrypt.h, CryptEncrypt, CryptDecrypt, etc.  The
sample I used was an NT console app with EncryptFile and DecryptFile
functions.

Jim Frisby



Quote:> We are having trouble creating a DLL in Visual C++
> that can be used in Visual Basic.  What we are trying

 
 
 

1. Media Player 7 ActiveX in Visual C++ and Visual Basic

Is it possible to use the Windows Media Player 7 Active X control in Visual
C++.

In Visual C++ I get the following error:
    >>> The ActiveX Control is not registered properly, or its type library
version number is incorrect.  Try registering the control by removing and
importing in the component gallery. <<<

    (I have tried to do what the message says, with no success)

In Visual Basic, I can add control to the form, but any call to the media
player (such as changing the URL) will cause a runtime error (-3)

The Media Player SDK documentation on line says the following:

in any applications that use Microsoft Visual Basic or Visual C++ through
IDispatch.  <<<

Can anyone throw some light on that statement.   Why doesn't it support
embedding with IDispatch??? and If I can't use IDispatch can I use VTABLE
binding?

My goal is to play WMV videos in a Visual C++ applications.  WMV files with
varying bitrates DO NOT PLAY correctly in Media Player 6.4.  So, I need to
use The 7.0 Player

    Thanks For Your Help

        Tim L

2. Slow Clock Issue Revisited

3. Visual Basic vs. Visual C++

4. Capturing Batch File or Command Line apps output in *my* app....

5. Visual C++ and Visual Basic 4.0 developers need

6. Constant Disconnects with IE6

7. Visual BASIC merges with Visual C++ ????

8. Error when running Office 2K applications from guest account

9. can install visual c++ 4, but not visual c++ 6

10. Is there a way to merge visual C++ 6.0 and Embedded visual C++ 4.0

11. Drag File from file manager to Visual C++ 4.0 like Visual C++ 2.2?

12. Visual C++ 4.2 vs. Visual C++ 4.0