Home All Groups Group Topic Archive Search About

How to link to a dll in vb.net

Author
29 Jun 2005 9:08 PM
Chris
I have a DLL that I would like to use in VB.NET but I am not sure how to
link to it.  It is called PerlinDLL.dll and is a dll that spits out a bitmap
of a fractal image.(link:
http://www.stanford.edu/~jjshed/perlin/index.html ) I do have the code that
I believe allows a C# program hook to it, but I do not know how to do it in
VB.NET.  Where does the dll need to reside?  system32 directory? My programs
bin directory?

Here is the C# code:

  [DllImport("PerlinDLL.dll")]
  static extern unsafe void TestBMP(void* ARGB32_pixels, int w, int h);
  [DllImport("PerlinDLL.dll")]
  static extern unsafe void GeneratePerlinTexture(void *ARGB32_pixels, int
w, int h);
  [DllImport("PerlinDLL.dll")]
  static extern void SetPerlinVars(float init_freq, float init_amp, float
persistance, int octaves, int random_seed);
  [DllImport("PerlinDLL.dll")]
  static extern void SetLinearInterpolation();
  [DllImport("PerlinDLL.dll")]
  static extern void SetCosineInterpolation();
  [DllImport("PerlinDLL.dll")]
  static extern void SetCubicInterpolation();
  [DllImport("PerlinDLL.dll")]
  static extern void InitializePalette(int r1, int g1, int b1, int r2, int
g2, int b2);
  [DllImport("PerlinDLL.dll")]
  static extern void AddColor(float pos, int r, int g, int b);
  [DllImport("PerlinDLL.dll")]
  static extern int GetColor(float f);
  [DllImport("PerlinDLL.dll")]
  static extern void SetClampAbs();
  [DllImport("PerlinDLL.dll")]
  static extern void SetClampTruncate();
  [DllImport("PerlinDLL.dll")]
  static extern void SetClampNormalize();
  [DllImport("PerlinDLL.dll")]
  static extern void SetOutputFlat();
  [DllImport("PerlinDLL.dll")]
  static extern void SetOutputTileable();
  [DllImport("PerlinDLL.dll")]
  static extern void SetOutputSphereMapped();

What is the vb.net equivilant?

Thank you so much!

Chris

Author
30 Jun 2005 12:32 AM
Ken Tucker [MVP]
Hi,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vaconCallingWindowsAPIs.asp

Ken
--------------
"Chris" <j**@shmoe.com> wrote in message
news:Ob1O36OfFHA.3904@TK2MSFTNGP14.phx.gbl...
I have a DLL that I would like to use in VB.NET but I am not sure how to
link to it.  It is called PerlinDLL.dll and is a dll that spits out a bitmap
of a fractal image.(link:
http://www.stanford.edu/~jjshed/perlin/index.html ) I do have the code that
I believe allows a C# program hook to it, but I do not know how to do it in
VB.NET.  Where does the dll need to reside?  system32 directory? My programs
bin directory?

Here is the C# code:

  [DllImport("PerlinDLL.dll")]
  static extern unsafe void TestBMP(void* ARGB32_pixels, int w, int h);
  [DllImport("PerlinDLL.dll")]
  static extern unsafe void GeneratePerlinTexture(void *ARGB32_pixels, int
w, int h);
  [DllImport("PerlinDLL.dll")]
  static extern void SetPerlinVars(float init_freq, float init_amp, float
persistance, int octaves, int random_seed);
  [DllImport("PerlinDLL.dll")]
  static extern void SetLinearInterpolation();
  [DllImport("PerlinDLL.dll")]
  static extern void SetCosineInterpolation();
  [DllImport("PerlinDLL.dll")]
  static extern void SetCubicInterpolation();
  [DllImport("PerlinDLL.dll")]
  static extern void InitializePalette(int r1, int g1, int b1, int r2, int
g2, int b2);
  [DllImport("PerlinDLL.dll")]
  static extern void AddColor(float pos, int r, int g, int b);
  [DllImport("PerlinDLL.dll")]
  static extern int GetColor(float f);
  [DllImport("PerlinDLL.dll")]
  static extern void SetClampAbs();
  [DllImport("PerlinDLL.dll")]
  static extern void SetClampTruncate();
  [DllImport("PerlinDLL.dll")]
  static extern void SetClampNormalize();
  [DllImport("PerlinDLL.dll")]
  static extern void SetOutputFlat();
  [DllImport("PerlinDLL.dll")]
  static extern void SetOutputTileable();
  [DllImport("PerlinDLL.dll")]
  static extern void SetOutputSphereMapped();

What is the vb.net equivilant?

Thank you so much!

Chris