CLSID_CNetworkListManager undeclared identifer - error - winapi

I am developing an application to get the networks available on the system. Trying to run the same on windows vista. (The below code is based on the link : http://msdn.microsoft.com/en-us/library/ms697388(VS.85).aspx)
Below is the Code Snippet:
#include "Netlistmgr.h"
#include "Objbase.h"
INetworkListManager* pNLM = NULL;
IEnumNetworks *pEnumNetworks = NULL;
hr = ::CoCreateInstance(CLSID_CNetworkListManager,
NULL,
CLSCTX_LOCAL_SERVER,
IID_INetworkListManager,
(LPVOID*) &pNLM);
error C2065:
'CLSID_CNetworkListManager' :
undeclared identifier
Kindly help... Have i missed any header files/Library files???
Thanks,
Suren

INetworkListManager comes with Vista and up, you need to make sure that you have #define WINVER=600 defined in your source before #include or in the project settings.
You also need to make sure that you have Platform SDK 6.0 and up, if your working with Visual Studio 2008 then you're already using it.

Related

basic_timed_mutex.hpp(159): fatal error C1001: An internal error has occurred in the compiler

I have problem when I am building project in Visual Studio 2010 for 64bit. I couldn't able to build for 64bit with boost library, I am getting below error. I can build for 32bit but not for 64bit.
\boost_1_49_0\boost\thread\win32\basic_timed_mutex.hpp(159): fatal error C1001: An internal error has occurred in the compiler
(compiler file 'f:\dd\vctools\compiler\utc\src\p2\wvm\mdmiscw.c', line 2704)
5 To work around this problem, try simplifying or changing the program near the locations listed above.
5> Please choose the Technical Support command on the Visual C++
5> Help menu, or open the Technical Support help file for more information
5> The command exited with code 2.
It is pointing error to the below code and ofcourse I can't change the boost library. I am confused with this error
void unlock()
{
long const offset=lock_flag_value;
long const old_count=BOOST_INTERLOCKED_EXCHANGE_ADD(&active_count,lock_flag_value);
if(!(old_count&event_set_flag_value) && (old_count>offset))
{
if(!win32::interlocked_bit_test_and_set(&active_count,event_set_flag_bit))
{
win32::SetEvent(get_event());
}
}
}
Can you please help me,
Thank you
Edited :
I am not sure where the error but I think its in the boost libraries, there is a cpp file like
Class a::a(, point, )
{
}
and the "point" is a namespace which is defined in a header file which is using boost libraries and it has following code
#include <boost/thread.hpp>
#include <boost/thread/recursive_mutex.hpp>
namespace point
{
// some work1
void fun()
{
boost::unique_lock< boost::recursive_mutex > lck(*m_RedrawMutex);
// some work2
}
// some work3
}
Answer :
It finally worked !! After two days of search, I found another way.I just changed the order of include path in the project header where it was using boost basic_timed_mutex.hpp. I placed boost include path at the top and it worked. It's strange!!!
I've had this same issue myself - and it seems to be related to certain code-blocks in boost itself. It appears to be caused by a bug in the MSVC compiler toolchain.
Disabling optimisation appears to solve the issue for many users As per this MSDN article - Source from MSDN suggesting this fix Souce on stack-overflow
I wish I could present a logical cause, or bug report on the issue, but for myself the problem was solved by upgrading to Boost 1.60.
That said, other uses have reported that trailing-slashes are the cause!
update:
After some browsing it appears this issue can be caused by everything from infinite-loops, though to templates types holding function pointers. and doesn't always list the actual-source of the error correctly (eg: it's not where the error message says it is). That said, disabling optimisation appears to solve the issue near universally - at the cost that your software may run slower.

Error when trying to load dll - An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

Iam using a 3rd party c++ dll in my asp.net web application.
dll - 64-bit
asp.net Platform - Any Cpu
asp.net Framework - 4.0 (vs 2010)
System Os - Win 7 Professional (64-bit)
I have placed the dll in the Applications folder and called the dll with its full path as:
[DllImport(#"D:\Application\Sampledll.dll",
EntryPoint = "SampleFunc",
CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.StdCall)]
public static extern int SampleFunc(char[] ch1, char[] ch2);
But I got the below result:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
When searched with the Error code: 0x8007000B - It meant 'Using 32-bit dll on 64-bit system'
But the dll is 64-bit dll....
Any how I tried the solution of this error by changing the Target Platform of VS to 'x86' & 'x64' and setting 'Enable 32-Bit Application' property of IIS to 'True'
But got the same error.........
Can any one help to get around this problem....
Error code 0x8007000B is the COM error code that represents the Win32 error ERROR_BAD_FORMAT. Normally when a 32 bit process tries to load a 64 bit DLL, or vice versa, the error code is ERROR_BAD_EXE_FORMAT which would appear as 0x800700C1 when wrapped in a COM error code.
Therefore, I think that the problem is not a 32/64 bit mismatch. The most likely explanation is that the DLL, or one of its dependencies, is corrupt.
In order to debug this I would remove the complexity of IIS. You've got added layers of p/invoke and IIS to deal with. First of all make sure that you can load this DLL from another native program. Create a 64 bit C++ console app in VS that does this:
#include <windows.h>
#include <iostream>
int main()
{
if (!LoadLibraryA("D:\\Application\\Sampledll.dll"))
{
std::cout << GetLastError() << std::endl;
}
}
See what happens when you run that. If you get an error code, what value is it? Is it ERROR_BAD_FORMAT? At this point I'd use Dependency Walker in Profile mode to try to work out which DLL is the trouble maker.

Need help in including lib file in my vc++ project

First of all i am a beginner in visual studio so please forgive and guide me if i m going wrong in some way , i am a java and php programmer so i am not new to programming
i want to develop a application which reads fingerprint , i use this device
http://www.egistec.com/en/sensors/fingerprint-es603wb.aspx
which i think uses Windows Biometric Framework , so i tried to run the code mentioned in this page
http://msdn.microsoft.com/en-us/library/windows/desktop/ee207405(v=vs.85).aspx
this is what i did
#include "stdafx.h"
#include "Windows.h"
#include "Stdio.h"
#include "Conio.h"
#include "Winbio.h"
int _tmain(int argc, _TCHAR* argv[])
{ HRESULT CaptureSample(); }
you can find the function CaptureSample() in the second link provided above.
As you can see in the they said to link Winbio.lib, i know that its a dll in system32 , i did some research and created a Winbio.def file and Winbio.lib file,
Now my problem is i dont know how to link the lib file , i added "Winbio.lib" in properties >>LInker >> Additional Dependencies
it shows me the following error
*error LNK2019: unresolved external symbol _WinBioOpenSession#28*
infact this error appears even if i remove it from Additional Dependencies
please tell me where i am going wrong , should i place the lib file in any specific directory ? should i copy the dll somewhere ? or something else ?
Linker > General > Additional library Directoreis
put the path to the lib
Linker > Input
Put the lib name.
You can find this if you do some googling.
If everything is fine and still does not work, very probable that your lib file is not generated correctly. You can then try use dynamic loading of your dll file.
http://msdn.microsoft.com/en-us/library/ms810279.aspx
First loadLibrary is called to get a handle to your dll, then getProcAddress is called to get the pointer to the function. Cast the pointer into the target function defined in your h file. Then you'll be able to call the function.
I had the same problem. Following steps helped me on VS 2015 Community Edition
Right click on the project > Properties.
Linker > Input > then in the Addition Dependencies put winbio.lib; to front

InterlockedPushListSList is missing. Where is it?

I am developing on a Windows Server 2008 box, with Visual Studio 2010 Ultimate, SP1. Unfortunately, the function InterlockedPushListSList is causing errors because it is undefined in my copy of WinBase.h.
Declaring the function myself does not work; linker errors occur. It looks like this function is not defined in the windows libraries for my compiler. But the documentation linked to above states that it is available for my operating system.
Some Googling has revealed that the API has been around since the development of Windows Longhorn, albeit from a non-official source, so there shouldn't be any reason for it to be missing from my point of view.
Does this function actually exist? If so, where can I get it?
I was able to reproduce your problem with MSVC 2010 and Windows SDK v7.0A. InterlockedPushListSList is not present in WinBase.h. When declaring it, I first also got a linking error... until I realized I forgot the extern "C" :-). Maybe you also forgot that? I could compile and link if I declared
extern "C"
PSLIST_ENTRY FASTCALL InterlockedPushListSList(
_Inout_ PSLIST_HEADER ListHead,
_Inout_ PSLIST_ENTRY List,
_Inout_ PSLIST_ENTRY ListEnd,
_In_ ULONG Count
);

LockWorkStation - Compilation error - identifier not found

I am writing an application in which I got to lock the computer screen (OS is Windows). My Application is in C++. For this purpose I used the LockWorkStation() API defined on msdn, http://msdn.microsoft.com/en-us/library/aa376875%28VS.85%29.aspx
I have included windows.h as told but still I am getting compilation error:
.\source.cpp(5) : error C3861: 'LockWorkStation': identifier not found
here is a sample code thats giving error.
#include <Windows.h>
int main()
{
LockWorkStation();
return 0;
}
Please tell me what I am missing here :(
I am using MS-Visual studio 2005.
Regards.
That function was not supported until Windows 2000. The header files are versioned to allow you to build for older versions of Windows. You're going to want to tell the compiler which minimum version of Windows you want to support as follows:
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
...
#include <windows.h>
If you open winuser.h, you can see that it is surrounded by #if(_WIN32_WINNT >= 0x0500) ... #endif, meaning that it is not available unless you are targeting Windows 2000 or higher.
See http://msdn.microsoft.com/en-us/library/aa383745(VS.85).aspx for more information on the version macros. There's also the new NTDDI_VERSION define where you can set them all at once.

Resources