Advertisement

C++ DLL's and other languages...

Started by October 14, 2000 08:41 AM
2 comments, last by jollyjeffers 24 years, 2 months ago
hi, I''m trying to write a C/C++ DLL for use in other languages - mainly VB (I need the speed of C++)... Anway, I''ve got it setup so if I pass a 1D array to the DLL (of memory) it can do stuff with the data there... Now I need it to work in 2D... for example, In VB you have: Dim Something(199,199) as Tile So how do I set it up in a C++ DLL? All I want it void DoStuff(DataType *Data,some parameters) { for (x=0;x<=10;x++) for (y=0;y<=10;y++) //Treat the variable at x,y in the array } } } Anyone help me out with this one?? many thanks; Jack,

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

The interface between a program and a .dll is C based. But you can have objects floating around doing stuff in the .dll.

    void DoStuff(DataType *Data, long x, long y)	{	for(long i=0;i<x;i++)		for(long j=0;j<y;j++)			//you cant do data<i>[j] becuse it works differently			Data[i*y+j] = i*j+i;//yes, you mult i by y and add j; i*j+i could be whatever you want	}    


good luck making a .dll! If you get the parameterization wrong in VB it explodes and takes down VB.

declare DoStuff lib ".\DoStuff.dll" (ByRef o ByVal??? Array, long x, long y)
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
cheers;

As for VB.. hehe
I know. I''ve taken down more than VB with a simple error using C++ DLL''s...
It''s worse when you do it with DirectDraw DMA - had to leave my computer alone for 1/2 an hour cos I fried the memory....

Jack,

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Hold on.

IT dont work. Any more help? please?

I was trying the following code

void AlterVisibilityArray(bool *data,long sX,long sY,long eX,Long eY,bool Value)
{
for (long X = sx; x<=ex; x++)
{
for (long Y = sy; y<=ey; y++)
{
data[x*ex+y] = value; //don work
} //End Y
} //End X
} //End function


Any ideas - It works fine (no errors) - just when you analyse the array not all the elements are changed - usually every other one. for example,

false true false false true false true false true
false true true false ... and so on

when I tried changing a "false" array to a "true array"

please help

Jack,

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement