473,320 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Please Help With C DLL

I am writing a short OpenGL application in Visual Basic. I need an
extension that I can't get from the VB side. I create a dll named
glFogCoordf_Vb.dll to do the work for me. The dll fails to see the OpenGL
commands. I am at a loss as to how this can be fixed. Any ideas on how to
fix the problem? The dll is being created in MS Visual C/C++ 6.0 using the
Win32 Dynamic-Link Library Wizard. My code is as follows...

-- glFogCoordf_vb.def --
LIBRARY glFogCoordf_vb

DESCRIPTION 'Volume Fog OpenGL Extension'

EXPORTS
glFogCoordfEXT

-- glFogCoordf_vb.h --
#ifdef GLFOGCOORDF_VB_EXPORTS
#define GLFOGCOORDF_VB_API __declspec(dllexport)
#else
#define GLFOGCOORDF_VB_API __declspec(dllimport)
#endif

GLFOGCOORDF_VB_API void APIENTRY glFogCoordfEXT(const float fCoord);

-- glFogCoordf_vb.cpp --
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows
headers

#include <windows.h>
#include <olectl.h>
#include <gl\gl.h>
#include "glFogCoordf_vb.h"

#pragma comment( lib, "opengl32.lib" )

typedef void (APIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); // Declare
Function Prototype
PFNGLFOGCOORDFEXTPROC glFogCoordfEXT_func = NULL; // Our glFogCoordfEXT
Function

int Extension_Init()
{
char Extension_Name[] = "EXT_fog_coord";

MessageBox(NULL, "Checkpoint 1", "Message", MB_OK);

// Allocate Memory For Our Extension String
char* glextstring=(char *)malloc(strlen((char
*)glGetString(GL_EXTENSIONS))+1);

MessageBox(NULL, "Checkpoint 2", "Message", MB_OK);
strcpy (glextstring,(char *)glGetString(GL_EXTENSIONS)); // Grab The
Extension List, Store In glextstring

MessageBox(NULL, glextstring, "Extensions", MB_OK);
if (!strstr(glextstring,Extension_Name)) // Check To See If The
Extension Is Supported
return FALSE; // If Not, Return FALSE

free(glextstring); // Free Allocated Memory

// Setup And Enable glFogCoordEXT
glFogCoordfEXT_func = (PFNGLFOGCOORDFEXTPROC)
wglGetProcAddress("glFogCoordfEXT");

return TRUE;
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
/* if (!Extension_Init()) {
return FALSE;
}
*/
case DLL_PROCESS_DETACH:
glFogCoordfEXT_func = NULL;
break;
}
return TRUE;
}

GLFOGCOORDF_VB_API void APIENTRY glFogCoordfEXT(const float fCoord)
{
if (glFogCoordfEXT_func == NULL) {
Extension_Init();
}

if (glFogCoordfEXT_func != NULL) {
glFogCoordfEXT_func((GLfloat)fCoord);
}
}

I get past Checkpoint 1 but the dll bombs on glGetString which I assume
means that the function isn't there. I have tried stepping through the code
during debug and it goes straight to strlen and complains about an invalid
memory address. This code was taken from a C application I wrote and it
works fine there. The OpenGL in the VB application works fine as well; as
long as I don't let it execute the call to the dll. Any help would be
greatly appreciated.

Thanks!
Matthew Hanna
Jul 19 '05 #1
1 2092
Matthew Hanna wrote:
I am writing a short OpenGL application in Visual Basic. I need an
extension that I can't get from the VB side. I create a dll named
glFogCoordf_Vb.dll to do the work for me. The dll fails to see the OpenGL
commands. I am at a loss as to how this can be fixed. Any ideas on how to
fix the problem? The dll is being created in MS Visual C/C++ 6.0 using the
Win32 Dynamic-Link Library Wizard. My code is as follows... [snip]
Thanks!
Matthew Hanna


You need help from the experts in a Microsoft newsgroup.
This newsgroup, news:comp.lang.c++, only discusses the _standard_
C++ language which has no facilities for DLLs or OpenGL.

See the FAQ and welcome.txt links below.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: HolaGoogle | last post by:
Hi all, Please help me with the following..it's realy urgent and i tried everything i could and i can't get it work properly!! Thanks in advance. Here's what i'm trying to accomplish: in my...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
3
by: Mark Broadbent | last post by:
could somebody please recommend a good book to prepare for exam Exam 70-320*: Developing XML Web Services and Server Components with Microsoft Visual C# and the Microsoft .NET Framework . One that...
13
by: Joner | last post by:
Hello, I'm having trouble with a little programme of mine where I connect to an access database. It seems to connect fine, and disconnect fine, but then after it won't reconnect, I get the error...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.