我是一名测量专业程序员,对编程不是很熟,现在想开发徕卡公司的geocom应用程序,但是高级开发模式需要调用dll文件,c#我初学,搞了半天也不明白,不知道有没有大虾帮帮我。这个dll应该是一个命令库,不想一条一条调用,不知道能不能把它当成类似于类一样的东西一起用。说明书上是这么写的
Programming in C/C++ is based on the well-known DLL concept, defined by Microsoft Corp. To compile a project successfully first you have to include the file com_pub.hpp, which defines all necessary constants, data types and function prototypes. Second geocoms2k.lib has to be included in the project, which enables the linker to resolve the DLL exported functions. To operate successfully the geocoms2k.dll file must be accessible for the operating system, hence it must be located in a directory, which the operating system looks up for the requested DLL file.
com_pub.hpp,geocoms2k.lib geocoms2k.dll 这三个文件我都有,就是不知道这么放程序里,我在项目里添加引用的时候能看到这个dll文件,但是提示错误,后来发现所有dll都会提示错误。没头绪,各位大虾给力啊!

解决方案 »

  1.   

    要像调用api动态库一样调用
    给个例子先将dll要用的函数逐个声明,如:
    [DllImport("Winmm.dll", CharSet=CharSet.Auto)]
    protected extern static bool PlaySound(string strFile, IntPtr hMod, int flag );然后用到的时候直接调用,如:
    PlaySound(“c:\\a.wav”, IntPtr.Zero, Flags);
      

  2.   

    不是吧,没有其他方法么?这个dll文件里头至少有上百个方法
      

  3.   

    这里边装的是全站仪的指令集,说不好会用到什么
    那可不可以这样,就是我自己把这些东西都添加进去,然后做成一个什么文件
    另外可以这样用么
    [DllImport("Winmm.dll", CharSet=CharSet.Auto)]
    protected extern static bool PlaySound(string strFile, IntPtr hMod, int flag );
    protected extern static bool XXXXX(string strFile, IntPtr hMod, int flag );
    ……
    一直添加下去?
      

  4.   

    不行,每个函数定义都需要[DllImport(...
      

  5.   

    那是没有办法的了。
    如果有C++demo程序的话,而你的使用又不是太复杂的话,你可以使用c++再次封装一下。
    把复杂的接口隐藏起来,将简单的接口抛出给C#调用。
      

  6.   

    好吧,我试试,import这个方法还不知道行不行呢。
    ps:楼上的头像好吓人啊……