Thread: Using functions?

  1. #16
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    I know. I wasn't explaining what it was to you.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #17
    Registered User
    Join Date
    Feb 2006
    Ive managed to debug it a little, and it doesnt seem to be the cause of my own dll, but the dll MY dll is based on: mysqldllerror.JPG

  3. #18
    Registered User
    Join Date
    Feb 2006
    Ive been doing some searching in the msdn files and i found that to enable C++ dlls to be used in VB, i need to add __stdcall in front of the function(in VC++). I tried this, but it did not help.

    EDIT: sry, removed the vb code
    Last edited by Diod; 02-16-2006 at 11:16 AM.

  4. #19
    Registered User
    Join Date
    Apr 2003
    This is my VB Code:
    Are you aware that this is a C++ forum?

  5. #20
    Registered User
    Join Date
    Feb 2006
    Hmm i actually got it to work. I can now connect through a VB6 project

    But i still cant send a query, it still crashes when i try to send a query, but it also crashes within a C++ project, so i think its a problem with my function. Also, it does not seem to return the "returns" in my VB project. And it also shows an error after i close the VB program after i use the connect function.

    This is my code:

    #include "stdafx.h"
    #include <winsock.h>
    #include <mysql.h>
    BOOL APIENTRY DllMain( HANDLE hModule, 
                           DWORD  ul_reason_for_call, 
                           LPVOID lpReserved
        return TRUE;
    char* __stdcall mysql_connect(char *server, char *user, char *password, char *database);
    char* __stdcall mysql_sendquery(char *query);
    char** __stdcall mysql_fetch_row();
    char* __stdcall mysql_closeconn();
       MYSQL *conn;
       MYSQL_RES *res;
       MYSQL_ROW row;
       char* __stdcall mysql_connect(char *server, char *user, char *password, char *database) {
    	conn = mysql_init(NULL);
    		if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0)) {
    			return "Error connecting";
    	return "Connected";
       char* __stdcall mysql_sendquery(char *query) {
    	if (mysql_query(conn, query)) {
    		return "Error with query";
    	return "Query successfull";
       char** __stdcall mysql_fetch_row() {
    	char** error;
    	error[1] = "Error fetching row";
    	res = mysql_use_result(conn);
    	while ((row = mysql_fetch_row(res)) != NULL) {
    	return row;
    	return error;
       char* __stdcall mysql_closeconn() {
    	return "Connection closed";

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  3. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM