Advertisement Jump to content


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


ImageLib (DevIL) in Visual Basic

This topic is 5630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m not much of a VB guy, but I''m having to use it for a project. I''m wondering if anyone can walk me through (simplistically) the process of using an external library, specifically ImageLib, which is now DevIL, in Visual Basic. In C++ I know to just link to the library, include the headers, and off I go... their website says that DevIL can be compiled under all of these different languages, but only seems to include C++ in the documentation. Any help would be appreciated.

Share this post

Link to post
Share on other sites
Under the Project | References menu, find and select the library. You should then be able to create an instance of the object that allows you to access the functionality:

''This is all pseudocode
Dim oDevilLib As DevilLib

Set oDevilLib = New DevilLib


Hope this helps.

Share this post

Link to post
Share on other sites
Hi - you could try using the declare keyword. Here''s an example from MSDN:

Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long

How it works:

-GetTempPath is the name of the function that you will call from VB.
-Lib is the .dll library - I think you can specify a path here (i.e., app.path & "\test.dll"), but I''m not sure
-Alias GetTempPathA (case sensitive) is the name of the function in the .dll.
-nBufferLenghth, and lpBuffer are the input variables.

When you call the function in your code, you would do something like this:

nResult = GetTempPath(nBufferLength, strTest)

This might work, but there are a lot of gotcha''s -- the .dll has to be coded in a certain way for VB to use it (I had one of our C++ developers write me a .dll library and it took us an entire day to get it to work correctly), and variable conversion can be a pain. Most all numeric values get translated into VB as longs.

If you have to pass pointers in, then you can use VB''s undocumented varptr and strptr functions to get the memory addresses of the variables in question. varptr get the memory address of a variable or an array. strptr gets the memory address of a string. Make sure you pass pointers byval.

If the .dll requires a structure an an input then you can specify this in the declare statement. for example:

Type structBlah
nVar1 as long
nVar2 as long
end type

Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As structBlah) As Long

Just be sure that you declare the type before you declare the external function.

There are two books that will help with this (if you are desparate enough to consider buying books):

Win32 API Programming with Visual Basic by Steven Roman
Visual Basic Developer''s Guide to the Win32 API by Steven Brown

Also, all of the above is documented in the msdn library, but not as in depth as it needs to be. There is also an excerpt from Steven Roman''s book in the msdn library.

I hope this helps and good luck-


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!