我想把一些默认数据写到一个动态连接库文件中(例如XXX.DLL中),然后程序启动时调用动态连接库
然后把数据填写到数组中。
 (1)、如何实现
  

解决方案 »

  1.   

    做一个dll,在vb中声明比如private declare function init lib "xxx.dll" ( byref d() as byte ) as long然后调用
      

  2.   

    只要你领会了这个,你的问题就可以解决了.【CBM666 的 DLL 制作流程】http://download.csdn.net/source/360283
      

  3.   

    vc中写dll如下.h

    #ifndef __INIT_VB_DATA_H__
    #define __INIT_VB_DATA_H__extern "C" __declspec( dllexport ) char * __stdcall h2d( IN char *h, OUT char *d );#endif.cpp中// init_vb_data.cpp : Defines the entry point for the DLL application.
    //#include "stdafx.h"
    #include "init_vb_data.h"int __stdcall
    vcinit( unsigned char *data, size_t length )
    {
    size_t i, j;
    for( i = 0; i < length; i += 256 )
    {
    for( j = 0; j < length - i; j++ )
    {
    *( data + i + j ) = ( unsigned char )j;
    }
    } return 0;
    }.def中
    [code=BatchFile]; init_vb_data.def : 声明 DLL 的模块参数。LIBRARY      "init_vb_data"DESCRIPTION 'vcinit'EXPORTS
        ;

    vcinit[/code]vb中Option Explicit
    Private Declare Function vcinit Lib "D:\JennyVenus\源程序\vc\init_vb_data\Debug\init_vb_data.dll" (ByRef buf As Byte, ByVal length As Long) As LongPrivate Sub Command2_Click()
        Dim a(0 To 99) As Byte
        Dim i As Long
        a(1) = 99
        Call vcinit(a(0), 100)
        For i = 0 To 99
            Debug.Print a(i)
        Next i
    End Sub
      

  4.   

    上面.h的声明贴乱了#ifndef __INIT_VB_DATA_H__
    #define __INIT_VB_DATA_H__extern "C" __declspec( dllexport ) int __stdcall vcinit( unsigned char *buf, size_t length );#endif