函数RasEnumConnections的第一个参数RASCONN结构体随着操作系统版本的不同而不同,对于不同的系统使用RasEnumConnections函数必须使用大小不同的RASCONN结构体.
于是我自己定义了这么一个类:
template <class RASCONNT>
class CRasDetectT
{
public:
CRasDetectT();
~CRasDetectT();
bool EnumConnections();
bool HangupAll();
bool Hangup(int index);
protected:
RASCONNT *m_lprasconn;
DWORD m_connectionCount; // 枚举获得的连接数目
DWORD m_structSize; // 当前系统RASCONN结构体的大小
};
每次定义这个类的对象时先检测操作系统版本,如果是win98就CRasDetectT<RASCONN98> obj,如果是win2000就CRasDetectT<RASCONN2000> obj;这个类工作的很好,可是这样每次都需要获取操作系统的版本,然后再定义对象,我嫌他太过于麻烦。
我希望能够提供一个这样的接口:
CRasDetectT<???>* RasDetectCreator();
这个函数自动返回一个对应当前操作系统版本的对象,我可以直接使用这个对象进行操作。但是这个函数应该返回什么类型呢?
于是我定义了一个虚基类:
class CRasDetectBase
{
public:
virtual bool EnumConnections() = 0;
virtual bool HangupAll() = 0;
virtual bool Hangup(int index) = 0;
}
然后CRasDetectT从它继承:
class CRasDetectT : public CRasDetectBase
这样我就可以
CRasDetectBase* RasDetectCreator(); // 这个函数返回一个接口,通过这个接口,我总可以得到正确的对象。
可是,一旦这么定义,我的类在Link的时候就出现错误了:
testtmp error LNK2019: 无法解析的外部符号 _RasEnumConnectionsA@12 ,该符号在函数 "public: virtual bool __thiscall CRasDetectT<struct RASCONN2000>::EnumConnections(void)" (?EnumConnections@?$CRasDetectT@URASCONN2000@@@@UAE_NXZ) 中被引用
请问各位大侠,我上面的设计有什么问题吗?一个模板类不能从一个虚基类中继承吗?如果不能,我该如何实现我的这种想法?
呵呵,写得太罗嗦了,非常感谢各位大侠把它看完了。~_~
16 个解决方案
#1
看半天了
解决不了,等高手来
关注一下!
解决不了,等高手来
关注一下!
#2
一个模板类不能从一个虚基类中继承吗?
应该是可以的,不知道你的模板类的声明和实现怎么写的
应该是可以的,不知道你的模板类的声明和实现怎么写的
#3
class CRasDetectBase
{
public:
virtual bool EnumConnections() = 0;
virtual bool HangupAll() = 0;
virtual bool Hangup(int index) = 0;
}
template <class RASCONNT>
class CRasDetectT : public CRasDetectBase
{
public:
CRasDetectT();
~CRasDetectT();
bool EnumConnections();
bool HangupAll();
bool Hangup(int index);
protected:
RASCONNT *m_lprasconn;
DWORD m_connectionCount; // 枚举获得的连接数目
DWORD m_structSize; // 当前系统RASCONN结构体的大小
};
在CRasDetectT类中实现了基类中的几个虚函数。
{
public:
virtual bool EnumConnections() = 0;
virtual bool HangupAll() = 0;
virtual bool Hangup(int index) = 0;
}
template <class RASCONNT>
class CRasDetectT : public CRasDetectBase
{
public:
CRasDetectT();
~CRasDetectT();
bool EnumConnections();
bool HangupAll();
bool Hangup(int index);
protected:
RASCONNT *m_lprasconn;
DWORD m_connectionCount; // 枚举获得的连接数目
DWORD m_structSize; // 当前系统RASCONN结构体的大小
};
在CRasDetectT类中实现了基类中的几个虚函数。
#4
呵呵是模板函数的问题。
你要把所有的模板函数的定义放在头文件里,而不是cpp文件里!!!
你要把所有的模板函数的定义放在头文件里,而不是cpp文件里!!!
#5
模板函数和内联函数都有个怪毛病,就是当你的编译单元用到它的时候他才会被编译,否则他就被忽
略,如果你把他们放在cpp文件里,一旦他所在的cpp文件没有用到它(使他实例化),那么编译器就视他
不存在了,结果其他的编译单元(其他cpp)文件要用到它时(在连接的时候),就会出现上述错误。
略,如果你把他们放在cpp文件里,一旦他所在的cpp文件没有用到它(使他实例化),那么编译器就视他
不存在了,结果其他的编译单元(其他cpp)文件要用到它时(在连接的时候),就会出现上述错误。
#6
imRainman(雨人):
我所有的申明和定义都是放在一个.h文件中的。只不过定义太长了,没有贴出来。
我所有的申明和定义都是放在一个.h文件中的。只不过定义太长了,没有贴出来。
#7
当然,如果你不想把他们放在头文件中,也可以对模板进行“显式实例化”
C++ Language Reference
Explicit InstantiationSee Also
Function Templates
Explicit instantiation lets you create an instantiation of a templated class or function without actually using it in your code. Since this is useful when you are creating library (.LIB) files that use templates for distribution, uninstantiated template definitions are not put into object (.OBJ) files.
The following explicitly instantiates MyStack for int variables and six items:
template class MyStack<int, 6>;
This statement creates an instantiation of MyStack without reserving any storage for an object; code is generated for all members.
The following explicitly instantiates only the constructor member function:
template MyStack<int, 6>::MyStack( void );
Visual C++ 5.0 and later supports explicit instantiation of function templates. Versions prior to 5.0 supported the explicit instantiation of class templates only. For example, the following code is now legal:
// explicit_instantiation.cpp
template<class T> void f(T)
{
}
// Instantiate f with the explicitly specified template
// argument 'int'
//
template void f<int> (int);
// Instantiate f with the deduced template argument 'char'
//
template void f(char);
int main()
{
}
Microsoft Specific
You can use the extern keyword to prevent the automatic instantiation of members. For example:
extern template class MyStack<int, 6>;
Similarly, you can mark specific members as being external and not instantiated as follows:
extern template MyStack<int, 6>::MyStack( void );
Note The extern keyword in the specialization only applies to member functions defined outside of the body of the class. Functions defined inside the class declaration are considered inline functions and are always instantiated.
END Microsoft Specific
See Also
Function Templates
--------------------------------------------------------------------------------
Send feedback on this topic to Microsoft
© Microsoft Corporation. All rights reserved.
C++ Language Reference
Explicit InstantiationSee Also
Function Templates
Explicit instantiation lets you create an instantiation of a templated class or function without actually using it in your code. Since this is useful when you are creating library (.LIB) files that use templates for distribution, uninstantiated template definitions are not put into object (.OBJ) files.
The following explicitly instantiates MyStack for int variables and six items:
template class MyStack<int, 6>;
This statement creates an instantiation of MyStack without reserving any storage for an object; code is generated for all members.
The following explicitly instantiates only the constructor member function:
template MyStack<int, 6>::MyStack( void );
Visual C++ 5.0 and later supports explicit instantiation of function templates. Versions prior to 5.0 supported the explicit instantiation of class templates only. For example, the following code is now legal:
// explicit_instantiation.cpp
template<class T> void f(T)
{
}
// Instantiate f with the explicitly specified template
// argument 'int'
//
template void f<int> (int);
// Instantiate f with the deduced template argument 'char'
//
template void f(char);
int main()
{
}
Microsoft Specific
You can use the extern keyword to prevent the automatic instantiation of members. For example:
extern template class MyStack<int, 6>;
Similarly, you can mark specific members as being external and not instantiated as follows:
extern template MyStack<int, 6>::MyStack( void );
Note The extern keyword in the specialization only applies to member functions defined outside of the body of the class. Functions defined inside the class declaration are considered inline functions and are always instantiated.
END Microsoft Specific
See Also
Function Templates
--------------------------------------------------------------------------------
Send feedback on this topic to Microsoft
© Microsoft Corporation. All rights reserved.
#8
你可以发到我的邮箱里,我帮你看看imRainman@hotmail.com
#9
呵呵,谢谢了。
要不我都贴出来吧:
#pragma once
#include "stdafx.h"
#include <windows.h>
#include "ras.h"
#include "raserror.h"
#include "rasdetect.h"
class CRasDetect
{
public:
virtual bool EnumConnections() = 0;
virtual bool HangupAll() = 0;
virtual bool Hangup(int index) = 0;
};
template <class RASCONNT>
class CRasDetectT : public CRasDetect
{
public:
CRasDetectT();
~CRasDetectT();
bool EnumConnections();
bool HangupAll();
bool Hangup(int index);
protected:
RASCONNT *m_lprasconn;
DWORD m_connectionCount; // 枚举获得的连接数目
DWORD m_structSize; // 当前系统RASCONN结构体的大小
};
template <class RASCONNT>
CRasDetectT<RASCONNT>::CRasDetectT()
{
m_structSize = sizeof(RASCONNT);
}
template <class RASCONNT>
CRasDetectT<RASCONNT>::~CRasDetectT()
{
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::EnumConnections()
{
m_lprasconn = (RASCONNT *)new BYTE[m_structSize];
DWORD dwCb;
dwCb = m_structSize;
m_lprasconn->dwSize = m_structSize;
DWORD dwErr = RasEnumConnections(
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
if (ERROR_BUFFER_TOO_SMALL == dwErr)
{
delete m_lprasconn;
m_lprasconn = (RASCONNT *)new BYTE[m_structSize];
m_lprasconn->dwSize = m_structSize;
dwErr = RasEnumConnections(
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
if(dwErr == ERROR_SUCCESS)
return true;
else
return false;
}
else if(dwErr == ERROR_SUCCESS)
return true;
else
return false;
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::Hangup(int index)
{
DWORD err = RasHangUp(m_lprasconn[index].hrasconn);
if(err == 0)
return true;
else
return false;
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::HangupAll()
{
bool result = true;
for(DWORD i = 0 ; i < m_connectionCount ; i++)
if(!Hangup(i))
result = false;
return result;
}
struct RASCONN2000
{
DWORD dwSize;
HRASCONN hrasconn;
CHAR szEntryName[ RAS_MaxEntryName + 1 ];
CHAR szDeviceType[ RAS_MaxDeviceType + 1 ];
CHAR szDeviceName[ RAS_MaxDeviceName + 1 ];
CHAR szPhonebook [ MAX_PATH ];
DWORD dwSubEntry;
GUID guidEntry;
};
要不我都贴出来吧:
#pragma once
#include "stdafx.h"
#include <windows.h>
#include "ras.h"
#include "raserror.h"
#include "rasdetect.h"
class CRasDetect
{
public:
virtual bool EnumConnections() = 0;
virtual bool HangupAll() = 0;
virtual bool Hangup(int index) = 0;
};
template <class RASCONNT>
class CRasDetectT : public CRasDetect
{
public:
CRasDetectT();
~CRasDetectT();
bool EnumConnections();
bool HangupAll();
bool Hangup(int index);
protected:
RASCONNT *m_lprasconn;
DWORD m_connectionCount; // 枚举获得的连接数目
DWORD m_structSize; // 当前系统RASCONN结构体的大小
};
template <class RASCONNT>
CRasDetectT<RASCONNT>::CRasDetectT()
{
m_structSize = sizeof(RASCONNT);
}
template <class RASCONNT>
CRasDetectT<RASCONNT>::~CRasDetectT()
{
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::EnumConnections()
{
m_lprasconn = (RASCONNT *)new BYTE[m_structSize];
DWORD dwCb;
dwCb = m_structSize;
m_lprasconn->dwSize = m_structSize;
DWORD dwErr = RasEnumConnections(
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
if (ERROR_BUFFER_TOO_SMALL == dwErr)
{
delete m_lprasconn;
m_lprasconn = (RASCONNT *)new BYTE[m_structSize];
m_lprasconn->dwSize = m_structSize;
dwErr = RasEnumConnections(
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
if(dwErr == ERROR_SUCCESS)
return true;
else
return false;
}
else if(dwErr == ERROR_SUCCESS)
return true;
else
return false;
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::Hangup(int index)
{
DWORD err = RasHangUp(m_lprasconn[index].hrasconn);
if(err == 0)
return true;
else
return false;
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::HangupAll()
{
bool result = true;
for(DWORD i = 0 ; i < m_connectionCount ; i++)
if(!Hangup(i))
result = false;
return result;
}
struct RASCONN2000
{
DWORD dwSize;
HRASCONN hrasconn;
CHAR szEntryName[ RAS_MaxEntryName + 1 ];
CHAR szDeviceType[ RAS_MaxDeviceType + 1 ];
CHAR szDeviceName[ RAS_MaxDeviceName + 1 ];
CHAR szPhonebook [ MAX_PATH ];
DWORD dwSubEntry;
GUID guidEntry;
};
#10
对了,下面这一句需要删除:
#include "rasdetect.h"
这个文件本身就是:rasdetect.h
#include "rasdetect.h"
这个文件本身就是:rasdetect.h
#11
RasEnumConnections(
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
RasEnumConnections( )在那儿?
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
RasEnumConnections( )在那儿?
#12
RasEnumConnections这是个系统函数,函数申明在"ras.h"里面。
#13
忘记定义了?我找个半天,一个细胞也没有找到~~~~
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::EnumConnections()
这上面这个函数里调用的。
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::EnumConnections()
这上面这个函数里调用的。
#14
你没有导入Rasapi32.lib!!!
#15
可以在项目的属性里设置。
或者加入:
#pragma comment( lib, "Rasapi32.lib" )
或者加入:
#pragma comment( lib, "Rasapi32.lib" )
#16
..........
我一直以为是我的模板用的不对。。。。。我。。。。。不说了。。。。。。给分。。。。。
我一直以为是我的模板用的不对。。。。。我。。。。。不说了。。。。。。给分。。。。。
#1
看半天了
解决不了,等高手来
关注一下!
解决不了,等高手来
关注一下!
#2
一个模板类不能从一个虚基类中继承吗?
应该是可以的,不知道你的模板类的声明和实现怎么写的
应该是可以的,不知道你的模板类的声明和实现怎么写的
#3
class CRasDetectBase
{
public:
virtual bool EnumConnections() = 0;
virtual bool HangupAll() = 0;
virtual bool Hangup(int index) = 0;
}
template <class RASCONNT>
class CRasDetectT : public CRasDetectBase
{
public:
CRasDetectT();
~CRasDetectT();
bool EnumConnections();
bool HangupAll();
bool Hangup(int index);
protected:
RASCONNT *m_lprasconn;
DWORD m_connectionCount; // 枚举获得的连接数目
DWORD m_structSize; // 当前系统RASCONN结构体的大小
};
在CRasDetectT类中实现了基类中的几个虚函数。
{
public:
virtual bool EnumConnections() = 0;
virtual bool HangupAll() = 0;
virtual bool Hangup(int index) = 0;
}
template <class RASCONNT>
class CRasDetectT : public CRasDetectBase
{
public:
CRasDetectT();
~CRasDetectT();
bool EnumConnections();
bool HangupAll();
bool Hangup(int index);
protected:
RASCONNT *m_lprasconn;
DWORD m_connectionCount; // 枚举获得的连接数目
DWORD m_structSize; // 当前系统RASCONN结构体的大小
};
在CRasDetectT类中实现了基类中的几个虚函数。
#4
呵呵是模板函数的问题。
你要把所有的模板函数的定义放在头文件里,而不是cpp文件里!!!
你要把所有的模板函数的定义放在头文件里,而不是cpp文件里!!!
#5
模板函数和内联函数都有个怪毛病,就是当你的编译单元用到它的时候他才会被编译,否则他就被忽
略,如果你把他们放在cpp文件里,一旦他所在的cpp文件没有用到它(使他实例化),那么编译器就视他
不存在了,结果其他的编译单元(其他cpp)文件要用到它时(在连接的时候),就会出现上述错误。
略,如果你把他们放在cpp文件里,一旦他所在的cpp文件没有用到它(使他实例化),那么编译器就视他
不存在了,结果其他的编译单元(其他cpp)文件要用到它时(在连接的时候),就会出现上述错误。
#6
imRainman(雨人):
我所有的申明和定义都是放在一个.h文件中的。只不过定义太长了,没有贴出来。
我所有的申明和定义都是放在一个.h文件中的。只不过定义太长了,没有贴出来。
#7
当然,如果你不想把他们放在头文件中,也可以对模板进行“显式实例化”
C++ Language Reference
Explicit InstantiationSee Also
Function Templates
Explicit instantiation lets you create an instantiation of a templated class or function without actually using it in your code. Since this is useful when you are creating library (.LIB) files that use templates for distribution, uninstantiated template definitions are not put into object (.OBJ) files.
The following explicitly instantiates MyStack for int variables and six items:
template class MyStack<int, 6>;
This statement creates an instantiation of MyStack without reserving any storage for an object; code is generated for all members.
The following explicitly instantiates only the constructor member function:
template MyStack<int, 6>::MyStack( void );
Visual C++ 5.0 and later supports explicit instantiation of function templates. Versions prior to 5.0 supported the explicit instantiation of class templates only. For example, the following code is now legal:
// explicit_instantiation.cpp
template<class T> void f(T)
{
}
// Instantiate f with the explicitly specified template
// argument 'int'
//
template void f<int> (int);
// Instantiate f with the deduced template argument 'char'
//
template void f(char);
int main()
{
}
Microsoft Specific
You can use the extern keyword to prevent the automatic instantiation of members. For example:
extern template class MyStack<int, 6>;
Similarly, you can mark specific members as being external and not instantiated as follows:
extern template MyStack<int, 6>::MyStack( void );
Note The extern keyword in the specialization only applies to member functions defined outside of the body of the class. Functions defined inside the class declaration are considered inline functions and are always instantiated.
END Microsoft Specific
See Also
Function Templates
--------------------------------------------------------------------------------
Send feedback on this topic to Microsoft
© Microsoft Corporation. All rights reserved.
C++ Language Reference
Explicit InstantiationSee Also
Function Templates
Explicit instantiation lets you create an instantiation of a templated class or function without actually using it in your code. Since this is useful when you are creating library (.LIB) files that use templates for distribution, uninstantiated template definitions are not put into object (.OBJ) files.
The following explicitly instantiates MyStack for int variables and six items:
template class MyStack<int, 6>;
This statement creates an instantiation of MyStack without reserving any storage for an object; code is generated for all members.
The following explicitly instantiates only the constructor member function:
template MyStack<int, 6>::MyStack( void );
Visual C++ 5.0 and later supports explicit instantiation of function templates. Versions prior to 5.0 supported the explicit instantiation of class templates only. For example, the following code is now legal:
// explicit_instantiation.cpp
template<class T> void f(T)
{
}
// Instantiate f with the explicitly specified template
// argument 'int'
//
template void f<int> (int);
// Instantiate f with the deduced template argument 'char'
//
template void f(char);
int main()
{
}
Microsoft Specific
You can use the extern keyword to prevent the automatic instantiation of members. For example:
extern template class MyStack<int, 6>;
Similarly, you can mark specific members as being external and not instantiated as follows:
extern template MyStack<int, 6>::MyStack( void );
Note The extern keyword in the specialization only applies to member functions defined outside of the body of the class. Functions defined inside the class declaration are considered inline functions and are always instantiated.
END Microsoft Specific
See Also
Function Templates
--------------------------------------------------------------------------------
Send feedback on this topic to Microsoft
© Microsoft Corporation. All rights reserved.
#8
你可以发到我的邮箱里,我帮你看看imRainman@hotmail.com
#9
呵呵,谢谢了。
要不我都贴出来吧:
#pragma once
#include "stdafx.h"
#include <windows.h>
#include "ras.h"
#include "raserror.h"
#include "rasdetect.h"
class CRasDetect
{
public:
virtual bool EnumConnections() = 0;
virtual bool HangupAll() = 0;
virtual bool Hangup(int index) = 0;
};
template <class RASCONNT>
class CRasDetectT : public CRasDetect
{
public:
CRasDetectT();
~CRasDetectT();
bool EnumConnections();
bool HangupAll();
bool Hangup(int index);
protected:
RASCONNT *m_lprasconn;
DWORD m_connectionCount; // 枚举获得的连接数目
DWORD m_structSize; // 当前系统RASCONN结构体的大小
};
template <class RASCONNT>
CRasDetectT<RASCONNT>::CRasDetectT()
{
m_structSize = sizeof(RASCONNT);
}
template <class RASCONNT>
CRasDetectT<RASCONNT>::~CRasDetectT()
{
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::EnumConnections()
{
m_lprasconn = (RASCONNT *)new BYTE[m_structSize];
DWORD dwCb;
dwCb = m_structSize;
m_lprasconn->dwSize = m_structSize;
DWORD dwErr = RasEnumConnections(
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
if (ERROR_BUFFER_TOO_SMALL == dwErr)
{
delete m_lprasconn;
m_lprasconn = (RASCONNT *)new BYTE[m_structSize];
m_lprasconn->dwSize = m_structSize;
dwErr = RasEnumConnections(
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
if(dwErr == ERROR_SUCCESS)
return true;
else
return false;
}
else if(dwErr == ERROR_SUCCESS)
return true;
else
return false;
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::Hangup(int index)
{
DWORD err = RasHangUp(m_lprasconn[index].hrasconn);
if(err == 0)
return true;
else
return false;
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::HangupAll()
{
bool result = true;
for(DWORD i = 0 ; i < m_connectionCount ; i++)
if(!Hangup(i))
result = false;
return result;
}
struct RASCONN2000
{
DWORD dwSize;
HRASCONN hrasconn;
CHAR szEntryName[ RAS_MaxEntryName + 1 ];
CHAR szDeviceType[ RAS_MaxDeviceType + 1 ];
CHAR szDeviceName[ RAS_MaxDeviceName + 1 ];
CHAR szPhonebook [ MAX_PATH ];
DWORD dwSubEntry;
GUID guidEntry;
};
要不我都贴出来吧:
#pragma once
#include "stdafx.h"
#include <windows.h>
#include "ras.h"
#include "raserror.h"
#include "rasdetect.h"
class CRasDetect
{
public:
virtual bool EnumConnections() = 0;
virtual bool HangupAll() = 0;
virtual bool Hangup(int index) = 0;
};
template <class RASCONNT>
class CRasDetectT : public CRasDetect
{
public:
CRasDetectT();
~CRasDetectT();
bool EnumConnections();
bool HangupAll();
bool Hangup(int index);
protected:
RASCONNT *m_lprasconn;
DWORD m_connectionCount; // 枚举获得的连接数目
DWORD m_structSize; // 当前系统RASCONN结构体的大小
};
template <class RASCONNT>
CRasDetectT<RASCONNT>::CRasDetectT()
{
m_structSize = sizeof(RASCONNT);
}
template <class RASCONNT>
CRasDetectT<RASCONNT>::~CRasDetectT()
{
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::EnumConnections()
{
m_lprasconn = (RASCONNT *)new BYTE[m_structSize];
DWORD dwCb;
dwCb = m_structSize;
m_lprasconn->dwSize = m_structSize;
DWORD dwErr = RasEnumConnections(
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
if (ERROR_BUFFER_TOO_SMALL == dwErr)
{
delete m_lprasconn;
m_lprasconn = (RASCONNT *)new BYTE[m_structSize];
m_lprasconn->dwSize = m_structSize;
dwErr = RasEnumConnections(
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
if(dwErr == ERROR_SUCCESS)
return true;
else
return false;
}
else if(dwErr == ERROR_SUCCESS)
return true;
else
return false;
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::Hangup(int index)
{
DWORD err = RasHangUp(m_lprasconn[index].hrasconn);
if(err == 0)
return true;
else
return false;
}
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::HangupAll()
{
bool result = true;
for(DWORD i = 0 ; i < m_connectionCount ; i++)
if(!Hangup(i))
result = false;
return result;
}
struct RASCONN2000
{
DWORD dwSize;
HRASCONN hrasconn;
CHAR szEntryName[ RAS_MaxEntryName + 1 ];
CHAR szDeviceType[ RAS_MaxDeviceType + 1 ];
CHAR szDeviceName[ RAS_MaxDeviceName + 1 ];
CHAR szPhonebook [ MAX_PATH ];
DWORD dwSubEntry;
GUID guidEntry;
};
#10
对了,下面这一句需要删除:
#include "rasdetect.h"
这个文件本身就是:rasdetect.h
#include "rasdetect.h"
这个文件本身就是:rasdetect.h
#11
RasEnumConnections(
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
RasEnumConnections( )在那儿?
(RASCONN*)m_lprasconn,
&dwCb,
&m_connectionCount);
RasEnumConnections( )在那儿?
#12
RasEnumConnections这是个系统函数,函数申明在"ras.h"里面。
#13
忘记定义了?我找个半天,一个细胞也没有找到~~~~
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::EnumConnections()
这上面这个函数里调用的。
template <class RASCONNT>
bool CRasDetectT<RASCONNT>::EnumConnections()
这上面这个函数里调用的。
#14
你没有导入Rasapi32.lib!!!
#15
可以在项目的属性里设置。
或者加入:
#pragma comment( lib, "Rasapi32.lib" )
或者加入:
#pragma comment( lib, "Rasapi32.lib" )
#16
..........
我一直以为是我的模板用的不对。。。。。我。。。。。不说了。。。。。。给分。。。。。
我一直以为是我的模板用的不对。。。。。我。。。。。不说了。。。。。。给分。。。。。