Convert C header declarations to VB module declarations

I am looking for anyone who has sufficient knowlege of both C and VB to take a C header file with DLL calling declarations in it and convert it to a VB module with the same declarations to allow calling the DLL functions.
I can provide the C sample calling code and header file.
Please contact me on if you are interested and I will send the C files.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

/* header */
extern "C" __declspec(dllexport) int maxFunc( int n1, int n2 );

/* c */
#include "MyFunctions.h"

int maxFunc( int n1, int n2 )
    return (n1 > n2) ? n1 : n2;

Public Declare Function maxFunc Lib "C:\mydll" (ByVal n1 As Integer, ByVal n2 As Integer) As Integer

Sub Test()
    Dim x, y
    Dim res
    x = 123..
    y = ....
    'call dll function
    res = maxFunc(x,y)
End Sub


watinAuthor Commented:
The above code seems to be an example of how a declaration and call are made in both C and VB.
Unfortunately I already have numerous of these but actually require a number of complex calls rewritten in VB.
If the writer wants to rewrite them for me I will send them and pay what is required but I have not so far been successful in trying to do so myself and I have no time left to keep trying.
post your header

Also - before you start - are the
C functions defined with the standard
call mechanism (ie pascal calling convention)? - if not you cant call
them from VB.

In that cas you would have to write a wrapper DLL which exports standard call
versions of the ones in your DLL and
internally loads and calls the 1st DLL.

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

watinAuthor Commented:
OK the header follows.
I don't know enough about calling conventions so answer your question above. Maybe you can tell by looking at it. If it needs a wrapper app then OK that's what I need. But however I need it urgently !

* Description: Contains the function prototypes for the exported API's
#include "prodrec.h"

//ActualCommand codes
#define nREAD_CELL                              1
#define nWRITE_CELL                              2
#define nCHECK_ALGO_STATUS                  6
#define nCHECK_COUNTER_STATUS            7
#define nACTIVATE_ALGO_PART1            8
#define nACTIVATE_ALGO_PART2            9
#define nDECREMENT_CELL                        10
#define nACTIVATE_PRODUCT                  11
#define nRESET_OR_ADD_DIST_COUNTER      12
#define nINCREMENT_COUNTER                  13

typedef struct _CELL_DATA {
short cellAddr;
short cellValue;

typedef struct _COMMANDSREC {
  short CommandIndex;
  short ActualCommand;
  short CellIndex;
  short ValIndex;
  short ACIndex;

typedef struct _SAFECOMMANDREC {
      short ActualCommand;
      short CellIndex;
      short ValIndex;
      short ACIndex;
      char prod_name[16];

 typedef struct _RESULTREC {
  short CellIndex;
  short ValIndex;
  short ACIndex;
 } RESULTREC;                              

unsigned long RbRtlShlDword( unsigned long theData, unsigned short cnt );
unsigned long RbRtlShrDword( unsigned long theData, unsigned short cnt );
unsigned short FindKeyPosition(int *u_key, int *d_key);

* Prototypes for exported API's

extern "C" short __declspec(dllexport) WINAPI SAFEInitGlobal(unsigned char*);

extern "C" unsigned short __declspec(dllexport) WINAPI DecodeKeyID(unsigned char*,
                                                          unsigned short*);  

extern "C" unsigned short __declspec(dllexport) WINAPI GenerateUpdateStr( unsigned char * GlobPtr,
                                                      SAFECOMMANDREC     *safe_commands,
                                                                          short             count,
                                                                          char           *updateStr,
                                                                          PROD_LIST  *prod_list_ptr);  
extern "C" unsigned short __declspec(dllexport) WINAPI ReadWizardDATFile(char*,
watinAuthor Commented:
Following is also the second header called by the first.

#ifndef __PRODREC__
#define __PRODREC__

//defines for activation types
#define STATIC 0
#define TRUSTED 1
#define DROP_IN 3
#define ACTIVE 4

#define MAX_PRODS 14
typedef unsigned short int WORD;

#pragma pack(1)
typedef struct {
      char cell_address;
      char product_id;
      char prod_name[17];
      WORD model;
      WORD algo1;
      WORD algo2;
      WORD password1;
      WORD password2;

typedef struct {
      PRODUCT_REC prod_list[MAX_PRODS];

WINAPI indicates pascal calling convention - so your ok there.

going to be some time before i can look at this - seeing as im at work.

but for now try this...

Private Declare Function SAFEInitGlobal Lib "YourDLL.DLL" (ByVal s As String) As Integer

if you can get this to work you're on your way.

another quick question

can you look at the exports of your DLL
(use quickview) and tell me what they
look like, i.e do they have any name

for example

is the exported name


or is it


or something similar

watinAuthor Commented:
Sorry Mike I don't even know what Quickview is or what you mean by "exports" from DLLs.

I have called numerous DLLs before using declarations similar to the one you suggest above.
That is not the problem.
It is the definition of the variables and structs/types passed by these calls and how they are written correctly in the declarations so they work.
quickview comes with windows
its an accessory which isnt installed by default - you can install it by
add remove programs/windows setup.

if you right click a dll you should get it as an option.

it is crucial to know the exports as VB
uses them to gain entry points into the

Next is coversion of you 1-st file
(second: same)

Private Type CELL_DATA
  cellAddr as Integer
  cellValue as Integer
End type

  CommandIndex as Integer
  ActualCommand as Integer
  CellIndex as Integer
  ValIndex as Integer
  ACIndex as Integer
End Type

 ActualCommand as Integer
 CellIndex as Integer
 ValIndex as Integer
 ACIndex as Integer
 prod_name as String*16
End Type

Private Type RESULTREC
  CellIndex as Integer
  short as Integer
  short as Integer
End Type
Prived Function RbRtlShlDword (theData as Long,cnt as Integer) as Long
' you code
End Function
Prived Function RbRtlShlDword( theData as Long,  cnt as Integer) as Long
' you code
End Function

Prived Function FindKeyPosition(u_key as Long , d_key as Long) as Integer
' you code
End Function

Private Declare Function SAFEInitGlobal Lib "mylib.dll" Alias "real_name" (str as String) as Integer

Private Declare Function DecodeKeyID Iib "mylib.dll" Alias "real_name" (str as String, _
   str1 as String,result as RESULTREC,us as Integer) as Integer

Private Declare Function GenerateUpdateStr Lib "mylib.dll" Alias "real_name" _
     (  GlobPtr as String,safe_commands as SAFECOMMANDREC, _
              count as String,
              updateStr as String, _
              prod_list_ptr as PROD_LIST) as  Integer
Private Declare Function  ReadWizardDATFile Lib "mylib.dll" Alias "real_name" _
 (str as String,prod_list_ptr  LIST_PTR) as Integer
Best Regards, Alex

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.