实例化对象时,dll import会出错 [英] dll import gives error when instantiating an object

查看:74
本文介绍了实例化对象时,dll import会出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我遇到了问题,我正在研究c ++程序,我已经导入了一个dll文件,我不知道它看起来如何,因为它只是一个给定的库,并给出了如何的API指南来自dll库的调用函数



我的导入行是:



Hi all, I am having a problem, I am working on the c++ program, I have imported a dll file which i don't know how it looks since it was just a given library and given an API guide on how to call functions from the dll library

My import line is:

#import "C:\Program Files\Aspect Software\Unified IP Shared\ccproosmsclient.dll" no_namespace





以及代码的以下部分是问题。





and in the following part of the code is the problem.

IAgentsPtr Agents = NULL;
IAgentPtr Agent = NULL;
long lCount = 0;
_variant_t vAgent ;
_variant_t vIndex ;
HRESULT hResult = NULL;
try
{    
    Agents = AgentMonitor->GetLoggedInAgents();
    if ((lCount = Agents->GetCount ()) > 0 )
    {
        for ( int sIndex = 1 ; sIndex <= lCount ; sIndex++ )
        {
            vIndex.vt = VT_I4 ;
            vIndex.intVal = sIndex;
            if ((hResult = Agents->raw_Item (vIndex,&vAgent)) == S_OK )
            {
                Agent = vAgent.pdispVal;
                printf("AgentIndex: %d\n",Agent->AgentIndex());
            }
        }
    }
}







以下错误如下:




the following gives the error below:

Agents = AgentMonitor->GetLoggedInAgents();

error1 C2027: use of undefined type 'AgentMonitor'

Error    2    error C2227: left of '->GetLoggedInAgents' must point to class/struct/union/generic type





我假设有我的dll拥有一切,只需在导入后使用它。



当我将鼠标光标放在AgentMonitor顶部时,它会显示struct AgentMonitor。



如何解决此问题。



提前致谢。



I am assuming that having my dll have everything and is just a matter of using it after importing it.

When I put the mouse cursor on top of AgentMonitor it shows struct AgentMonitor.

How can I resolve this.

Thanks in advance.

推荐答案

假设 AgentMonitor 是一个类而 GetLoggedInAgents()是一个静态函数,那么正确的代码将是be:

Assuming that AgentMonitor is a class and GetLoggedInAgents() is a static function, then the correct code would be:
Agents = AgentMonitor::GetLoggedInAgents();



如果它不是静态的那么你需要创建一个ins AgentMonitor 的类似:


If it is not static then you need to create an instance of AgentMonitor like:

AgentMonitor agentMonitor;
Agents = agentMonitor.GetLoggedInAgents();

// or

AgentMonitor* pagentMonitor = new AgentMonitor();
Agents = pagentMonitor->GetLoggedInAgents();


Thanks Richard,  AgentMonitor is a class and GetLoggedInAgents() is a function but I cant confirm if is static or non static because their implementation are within the dll and I am just importing the dll to my source and the instruction as the say from the API guide that I was supplied.

The following is a qoute from an API:
AgentMonitor<

This section describes the methods within the AgentMonitor class. You have access to these

methods when you instantiate an AgentMonitor object





I couldn't get it to work.


有谁知道如何解决这个问题?
Does anyone know how can i resolve this?


这篇关于实例化对象时,dll import会出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆