• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.


This topic is now archived and is closed to further replies.


VB and DLLs

1 post in this topic


I'm having the following problem:

I have this function : GetNumber (char[80] string, int number); in a dll named Funcs.dll
this dll was done in vc and I now need to use it in vb, can someone help me ?

Bruno Sousa aka Akura
Founder and programmer - Magick.pt


Share this post

Link to post
Share on other sites
It is pretty easy actually, in a module (*.bas) in the declarations section define your function like so....

Declare Function SomeFunction Lib "mydll.dll" (ByVal param1 as Integer, param2 as String) as Integer

Declare {Function|Sub} (Name of Sub) Lib "(name of dll)" [(parameters)] [as (type)]

{ | } = required but can be either or
[ ] = not required
( ) = required but may vary depending on the situation

That is the basic declaration, but let me warn you. If the dll isn't in the path (i.e. the windows\system folder) it won't find it, vb is very stingy about this for some reason, you need to specify the exact path. (Anyone out there know why this is?) So you need to name the exact path of the dll in order for vb to find it. If it is in a folder called project you would change the part "mydll.dll" to "c:\project\mydll.dll".

In the parameter list you will need to convert your C types into VB types, most will convert to long, somewhere in the help there is a list of what turns into what. The ByVal, if you didn't know, alters the way the parameter is passed. Normally VB passes by reference, this forces it to pass by value (like C normally does).

For your function I believe the C equivalent would be...

Declare Sub GetNumber Lib "path\Funcs.dll" (MyString as String, ByVal number as Long)

I could be wrong on the string conversion because the string in your function is of a definite size (try "MyString as String * 80" if it doesn't work). One last note about what I did, I changed the parameter named string to MyString. You can do this since the dll doesn't store the name of the parmeters, just the types. Since string is a keyword in vb, I changed it to MyString.

Now it should work...

If that doesn't work check the following...

First of all the answer differs if it was you who made the dll or am using someone elses.

If you made the dll here is what has to be done....

First make sure that all the functions you want to use in vb have the modifier "_stdcall"

Ex: void _stdcall somefunction();
(note the following would also be fine because they are the same)
void WINAPI somefunction(); //..or..
void PASCAL somefunction();

All of the above work, what this does is tell the compiler to compile the functions according to the standard calling convention used by most programming languages (C uses the "C calling convetion" as does C++)

Now thats done, time to tell the compiler what functions need to be sent to the dll client. Use a *.def file. VC doesn't have an express way of creating one, so your going to have to do it manually. Create a txt file but force it to use the def extention. Even if you don't tell it to use the def file it will automatically. You can also name it anything you like, and it will still use it (so long as it has the .def at the end) In the def file use the following format...

FirstFunction @ 1
SecondFunction @ 2

Keeping listing them like this(just replace FirstFuction with the name of the first function you want in the dll), you don't have to give it the parameters to the function, just the name. (note the caps on EXPORTS it is needed for it to work, a def is case sensitive) One other thing, you don't need to include all the functions you made in the def file, just the ones you want other programs to use.

That covers it, if you didn't make the dll and you defined it in vb like the above try other types. If the person didn't use the _stdcall modifier on the functions then put the functions in a def file it won't work.

Quick question to those that know, why is it when you try to do dll's in VC the easy way with "__declspec(dllexport)" in combination with _stdcall it doesn't work? I would really like to know, it would make at least my life a little easier.


PS I wrote this up pretty quickly so if I left anything out that you have a question on just reply.

[This message has been edited by Omalacon (edited October 05, 1999).]


Share this post

Link to post
Share on other sites