c# - DLL importation -


i have soft (using c#.net) able flash 2 microcontroller (cpu/pic). have vb6 dll, unfortunately can't use in vs. found development kit wrotte in cpp

this kit contain:

  • a file flasher.lib -> can't see source code

  • // flasher.exp -> can't see source code

  • // dll_interface.bas

sample dll_interface.bad :

option explicit  'dll function declarations  declare function setcom lib "st10flasher.dll" (byval portname$, byval comspeed long) long  declare function loadfile lib "st10flasher.dll" (byval filename$, byref fsize long) long  declare function initmonitor lib "st10flasher.dll" (byval device any) long  declare function programflash lib "st10flasher.dll" () long  declare function geterror lib "st10flasher.dll" (byval bufferforstatus any) long 
  • // basicinterface.h

sample basicinterface.h

#ifndef _basic_interface_h #define _basic_interface_h  #ifdef __cplusplus extern "c"  { #endif  #ifndef st10flasher_api #define st10flasher_api __declspec(dllimport) // import flasher function #endif  // communication function st10flasher_api unsigned int pascal setcom(char *portname, unsigned int comspeed); st10flasher_api unsigned int pascal closecom(void); st10flasher_api unsigned int pascal comiskline(void); st10flasher_api unsigned int pascal setcomspeed(char *portname, unsigned int comspeed); st10flasher_api unsigned int pascal calibratespeed(char *portname, unsigned int comspeed); st10flasher_api unsigned int pascal isavailablebaudrate(const double frequency,const unsigned int     baudrate); 

i have no idea how use it. if have idea please :) ! thank's lot !

you shouldn't reference dll using 'add reference'. instead, place dll next c# exe you're using. have example of how in vb.net, need translate code c#:

you need put in c# code:

  [dllimport(@"st10flasher.dll")]   public static extern long setcom(string portname, long int comspeed); 

then can call c# method. e.g.:

  long x = setcom("myport", 1600); 

for more help, google 'platform invoke' (also called p/invoke).


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -