显示调用dll

Posted pond-zzc

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了显示调用dll相关的知识,希望对你有一定的参考价值。

原dll中导出的接口如图:

技术图片

 

 

 

Head.h:


struct zint_render_line
float x, y, length, width;
struct zint_render_line *next; /* Pointer to next line */
;

struct zint_render_string
float x, y, fsize;
float width; /* Suggested string width, may be 0 if none recommended */
int length;
unsigned char *text;
struct zint_render_string *next; /* Pointer to next character */
;

struct zint_render_ring
float x, y, radius, line_width;
struct zint_render_ring *next; /* Pointer to next ring */
;

struct zint_render_hexagon
float x, y;
struct zint_render_hexagon *next; /* Pointer to next hexagon */
;

struct zint_render
float width, height;
struct zint_render_line *lines; /* Pointer to first line */
struct zint_render_string *strings; /* Pointer to first string */
struct zint_render_ring *rings; /* Pointer to first ring */
struct zint_render_hexagon *hexagons; /* Pointer to first hexagon */
;
struct zint_symbol
int symbology;
int height;
int whitespace_width;
int border_width;
int output_options;
char fgcolour[10];
char bgcolour[10];
char outfile[256];
float scale;
int option_1;
int option_2;
int option_3;
int show_hrt;
int input_mode;
int eci;
unsigned char text[128];
int rows;
int width;
char primary[128];
unsigned char encoded_data[200][143];
int row_height[200]; /* Largest symbol is 189 x 189 Han Xin */
char errtxt[100];
char *bitmap;
int bitmap_width;
int bitmap_height;
unsigned int bitmap_byte_length;
float dot_size;
struct zint_render *rendered;
;
#define ZINT_VERSION_MAJOR 2
#define ZINT_VERSION_MINOR 5
#define ZINT_VERSION_RELEASE 1

/* Tbarcode 7 codes */
#define BARCODE_CODE11 1
#define BARCODE_C25MATRIX 2
#define BARCODE_C25INTER 3
#define BARCODE_C25IATA 4
#define BARCODE_C25LOGIC 6
#define BARCODE_C25IND 7
#define BARCODE_CODE39 8
#define BARCODE_EXCODE39 9
#define BARCODE_EANX 13
#define BARCODE_EANX_CHK 14
#define BARCODE_EAN128 16
#define BARCODE_CODABAR 18
#define BARCODE_CODE128 20
#define BARCODE_DPLEIT 21
#define BARCODE_DPIDENT 22
#define BARCODE_CODE16K 23
#define BARCODE_CODE49 24
#define BARCODE_CODE93 25
#define BARCODE_FLAT 28
#define BARCODE_RSS14 29
#define BARCODE_RSS_LTD 30
#define BARCODE_RSS_EXP 31
#define BARCODE_TELEPEN 32
#define BARCODE_UPCA 34
#define BARCODE_UPCA_CHK 35
#define BARCODE_UPCE 37
#define BARCODE_UPCE_CHK 38
#define BARCODE_POSTNET 40
#define BARCODE_MSI_PLESSEY 47
#define BARCODE_FIM 49
#define BARCODE_LOGMARS 50
#define BARCODE_PHARMA 51
#define BARCODE_PZN 52
#define BARCODE_PHARMA_TWO 53
#define BARCODE_PDF417 55
#define BARCODE_PDF417TRUNC 56
#define BARCODE_MAXICODE 57
#define BARCODE_QRCODE 58
#define BARCODE_CODE128B 60
#define BARCODE_AUSPOST 63
#define BARCODE_AUSREPLY 66
#define BARCODE_AUSROUTE 67
#define BARCODE_AUSREDIRECT 68
#define BARCODE_ISBNX 69
#define BARCODE_RM4SCC 70
#define BARCODE_DATAMATRIX 71
#define BARCODE_EAN14 72
#define BARCODE_CODABLOCKF 74
#define BARCODE_NVE18 75
#define BARCODE_JAPANPOST 76
#define BARCODE_KOREAPOST 77
#define BARCODE_RSS14STACK 79
#define BARCODE_RSS14STACK_OMNI 80
#define BARCODE_RSS_EXPSTACK 81
#define BARCODE_PLANET 82
#define BARCODE_MICROPDF417 84
#define BARCODE_ONECODE 85
#define BARCODE_PLESSEY 86

/* Tbarcode 8 codes */
#define BARCODE_TELEPEN_NUM 87
#define BARCODE_ITF14 89
#define BARCODE_KIX 90
#define BARCODE_AZTEC 92
#define BARCODE_DAFT 93
#define BARCODE_MICROQR 97

/* Tbarcode 9 codes */
#define BARCODE_HIBC_128 98
#define BARCODE_HIBC_39 99
#define BARCODE_HIBC_DM 102
#define BARCODE_HIBC_QR 104
#define BARCODE_HIBC_PDF 106
#define BARCODE_HIBC_MICPDF 108
#define BARCODE_HIBC_BLOCKF 110
#define BARCODE_HIBC_AZTEC 112

/* Tbarcode 10 codes */
#define BARCODE_DOTCODE 115
#define BARCODE_HANXIN 116

/* Zint specific */
#define BARCODE_AZRUNE 128
#define BARCODE_CODE32 129
#define BARCODE_EANX_CC 130
#define BARCODE_EAN128_CC 131
#define BARCODE_RSS14_CC 132
#define BARCODE_RSS_LTD_CC 133
#define BARCODE_RSS_EXP_CC 134
#define BARCODE_UPCA_CC 135
#define BARCODE_UPCE_CC 136
#define BARCODE_RSS14STACK_CC 137
#define BARCODE_RSS14_OMNI_CC 138
#define BARCODE_RSS_EXPSTACK_CC 139
#define BARCODE_CHANNEL 140
#define BARCODE_CODEONE 141
#define BARCODE_GRIDMATRIX 142

// Output options
#define BARCODE_NO_ASCII 1
#define BARCODE_BIND 2
#define BARCODE_BOX 4
#define BARCODE_STDOUT 8
#define READER_INIT 16
#define SMALL_TEXT 32
#define BOLD_TEXT 64
#define CMYK_COLOUR 128
#define BARCODE_DOTTY_MODE 256

// Input data types
#define DATA_MODE 0
#define UNICODE_MODE 1
#define GS1_MODE 2
#define KANJI_MODE 3
#define SJIS_MODE 4

// Data Matrix specific options
#define DM_SQUARE 100
#define DM_DMRE 101

// Warning and error conditions
#define ZINT_WARN_INVALID_OPTION 2
#define ZINT_WARN_USES_ECI 3
#define ZINT_ERROR_TOO_LONG 5
#define ZINT_ERROR_INVALID_DATA 6
#define ZINT_ERROR_INVALID_CHECK 7
#define ZINT_ERROR_INVALID_OPTION 8
#define ZINT_ERROR_ENCODING_PROBLEM 9
#define ZINT_ERROR_FILE_ACCESS 10
#define ZINT_ERROR_MEMORY 11

// Raster file types
#define OUT_BUFFER 0
#define OUT_PNG_FILE 100
#define OUT_BMP_FILE 120
#define OUT_GIF_FILE 140
#define OUT_PCX_FILE 160


class CloadDll

public:

protected:
private:
;

main.cpp :

//#include "zlib.h"
//#include "zint.h"
#include <string>
#include "Windows.h"
#include "Head.h"

typedef struct zint_symbol*(*ZBarcode_Create)();
typedef int (*ZBarcode_Encode)(struct zint_symbol *symbol, unsigned char *input, int length);
typedef int (*ZBarcode_Print)(struct zint_symbol *symbol, int rotate_angle);
typedef void (*ZBarcode_Delete)(struct zint_symbol *symbol);
int main()

ZBarcode_Create zbarcode_create;
ZBarcode_Encode zbarcode_encode;
ZBarcode_Print zbarcode_print;
ZBarcode_Delete zbarcode_delete;
HINSTANCE hdll;
hdll = LoadLibrary("D:\\\\opt\\\\lib\\\\libzint.dll");
if (hdll==NULL)

FreeLibrary(hdll);

zbarcode_create=(ZBarcode_Create)GetProcAddress(hdll,"ZBarcode_Create");
if (zbarcode_create==NULL)

FreeLibrary(hdll);

zbarcode_encode=(ZBarcode_Encode)GetProcAddress(hdll,"ZBarcode_Encode");
if (zbarcode_encode==NULL)

FreeLibrary(hdll);

zbarcode_print=(ZBarcode_Print)GetProcAddress(hdll,"ZBarcode_Print");
if (zbarcode_print==NULL)

FreeLibrary(hdll);


zbarcode_delete=(ZBarcode_Delete)GetProcAddress(hdll,"ZBarcode_Delete");
if (zbarcode_delete==NULL)

FreeLibrary(hdll);


struct zint_symbol *my_symbol = zbarcode_create();
my_symbol->symbology=BARCODE_QRCODE;
my_symbol->show_hrt=0;//不显示字符到条形码下面
char *testvalue = "d:\\\\opt\\\\test5.bmp";
strcpy_s(my_symbol->outfile , testvalue);
int ret = zbarcode_encode(my_symbol, (unsigned char*)"ffdfsfsfdsX",0);
zbarcode_print(my_symbol,0);
zbarcode_delete(my_symbol);

return 0;


以上是关于显示调用dll的主要内容,如果未能解决你的问题,请参考以下文章

C#怎么调用C++的dll?

静态库 动态库 调用

从 C++ 调用 dll 函数

C#调用C++写的DLL总结

Qt Dll总结——创建及使用Qt的Dll(转载)

如何修复从Delphi应用程序调用它时在C ++ DLL中的MessageBox中显示的无效字符?