Click here to Skip to main content
15,917,859 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: MultiColumn ListBox Pin
CPallini30-Mar-07 4:42
mveCPallini30-Mar-07 4:42 
GeneralRe: MultiColumn ListBox Pin
deville7530-Mar-07 5:57
deville7530-Mar-07 5:57 
GeneralYou're welcome Pin
CPallini30-Mar-07 7:46
mveCPallini30-Mar-07 7:46 
GeneralRe: MultiColumn ListBox Pin
ThatsAlok1-Apr-07 21:08
ThatsAlok1-Apr-07 21:08 
QuestionHow to get Logged in user name using my own windows service application Pin
anumadhu30-Mar-07 3:34
anumadhu30-Mar-07 3:34 
AnswerRe: How to get Logged in user name using my own windows service application Pin
Johpoke30-Mar-07 9:54
Johpoke30-Mar-07 9:54 
AnswerRe: How to get Logged in user name using my own windows service application Pin
JudyL_MD30-Mar-07 10:17
JudyL_MD30-Mar-07 10:17 
QuestionRe: How to get Logged in user name using my own windows service application [modified] Pin
anumadhu2-Apr-07 0:30
anumadhu2-Apr-07 0:30 
Hello friends...

Thanks for your comments. I am taking help from the following article provided with Codeproject:

http://www.codeproject.com/vb/net/Windows_Service.asp

What i understand from this is, we can have access to the WMI. This WMI shows all the information regarding the various processes running in machine. As i want to get the username in which i am currently logged-in, So, i am using the Win32_Process (which gives the name of process explorer... and the substring of, name of process explorer contains the currently logged-in username(eg.. user_nameprocess.exe) . Using string operations... i am trying to extract that particular username part of the process explorer name.

Now,Taking help of this, i have added System.Management reference to my project (VC++.NET/windows XP) and then i got two files namely ROOT.CIMV2.Win32_Process.h/cpp with my project name. And in the ROOT.CIMV2.Win32_Process.cpp contains following lines of code:

#include Stdafx.h
#include ROOT.CIMV2.Win32_Process.h

After this i added System refrence through the project properties.

But while building this project, i am getting some errors in these new files ROOT.CIMV2.Win32_Process.h/cpp.

and command line options are:

C/C++ Command line options:
/Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FD /EHa /MDd /Yu"stdafx.h" /Fp"Debug\myservice.pch" /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W0 /nologo /c /Zi /clr:pure /TP /errorReport:prompt /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Management.dll" /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll"

Linker Command Line Options:
/OUT:"D:\Apr\2\myservice\Debug\myservice.exe" /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"Debug\myservice.exe.intermediate.manifest" /DEBUG /ASSEMBLYDEBUG /PDB:"d:\Apr\2\myservice\debug\myservice.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 /FIXED:No /ERRORREPORT:PROMPT setupapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

And stdafx.h file looks like this:

#pragma once

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers

// TODO: reference additional headers your program requires here

#define _AFXDLL
/*I included this, bcoz if i don't, then i m getting an build error: D:\Microsoft Visual Studio 8\VC\atlmfc\include\afx.h(24) : fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
*/


#pragma warning (disable:4430)
#include "ROOT.CIMV2.Win32_Process.h"
#include "afxdb.h"
#include <initguid.h>
#include <setupapi.h>
#include <dbt.h>
#include "cfgmgr32.h"

And if i put the #include _AFXDLL, then i am getting the following errors:

WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)
D:\Microsoft Visual Studio 8\VC\atlmfc\include\afxv_w32.h(242) : error C3641: 'DrawState' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\afxv_w32.h(260) : error C3641: 'DrawStatusText' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\PlatformSDK\include\winbase.h(1849) : error C3641: 'FreeResource' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\afxv_w32.h(274) : error C3641: 'UnlockResource' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(90) : error C3641: 'InterlockedExchangePointer' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(104) : error C3641: 'ATL::_AtlGetThreadACPFake' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(130) : error C3641: 'ATL::_AtlGetThreadACPReal' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(137) : error C3641: 'ATL::_AtlGetThreadACPThunk' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(147) : error C2440: '=' : cannot convert from 'UINT (__clrcall *)(void) throw()' to 'ATL::ATLGETTHREADACP'
Address of a function yields __clrcall calling convention in /clr:pure and /clr:safe; consider using __clrcall in target type
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(151) : error C2440: '=' : cannot convert from 'UINT (__clrcall *)(void) throw()' to 'ATL::ATLGETTHREADACP'
Address of a function yields __clrcall calling convention in /clr:pure and /clr:safe; consider using __clrcall in target type
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(158) : error C3641: 'ATL::_AtlGetConversionACP' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(594) : error C3641: 'AtlA2WHelper' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(613) : error C3641: 'AtlW2AHelper' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(631) : error C3641: 'AtlA2WHelper' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(636) : error C3641: 'AtlW2AHelper' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atlconv.h(589) : error C3641: 'AtlDevModeW2A' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atltrace.h(64) : error C2440: 'default argument' : cannot convert from 'int (__cdecl *)(int,const char *,int,const char *,const char *,...)' to 'ATL::CTrace::fnCrtDbgReport_t'
Address of a function yields __clrcall calling convention in /clr:pure and /clr:safe; consider using __clrcall in target type
D:\Microsoft Visual Studio 8\VC\atlmfc\include\atltrace.h(143) : fatal error C1903: unable to recover from previous error(s); stopping compilation

NOTE: I have not used windows service Template (provided with VC++.Net 2005). I have just used the windows.h advapi32.dll.

Any kind of help or clue is greatly thankful...

Thanks







-- modified at 6:49 Monday 2nd April, 2007

Anee

AnswerRe: How to get Logged in user name using my own windows service application Pin
ThatsAlok1-Apr-07 21:07
ThatsAlok1-Apr-07 21:07 
QuestionWindows XP theme Pin
Farhat Aisha30-Mar-07 3:16
Farhat Aisha30-Mar-07 3:16 
AnswerRe: Windows XP theme Pin
Mark Salsbery30-Mar-07 8:17
Mark Salsbery30-Mar-07 8:17 
AnswerRe: Windows XP theme Pin
Michael Dunn30-Mar-07 19:23
sitebuilderMichael Dunn30-Mar-07 19:23 
GeneralRe: Windows XP theme Pin
Farhat Aisha4-Apr-07 4:12
Farhat Aisha4-Apr-07 4:12 
QuestionAbout Multicast. Help Pin
kcynic30-Mar-07 2:35
kcynic30-Mar-07 2:35 
QuestionRe: About Multicast. Help Pin
Mark Salsbery30-Mar-07 7:07
Mark Salsbery30-Mar-07 7:07 
AnswerRe: About Multicast. Help Pin
kcynic30-Mar-07 13:41
kcynic30-Mar-07 13:41 
GeneralRe: About Multicast. Help Pin
Mark Salsbery31-Mar-07 6:37
Mark Salsbery31-Mar-07 6:37 
QuestionSTARTTLS Command Pin
neha.agarwal2730-Mar-07 1:49
neha.agarwal2730-Mar-07 1:49 
QuestionUsing WebService in C++ Pin
Tyler4530-Mar-07 1:41
Tyler4530-Mar-07 1:41 
AnswerRe: Using WebService in C++ Pin
Programm3r30-Mar-07 1:55
Programm3r30-Mar-07 1:55 
AnswerRe: Using WebService in C++ Pin
Tyler4530-Mar-07 2:31
Tyler4530-Mar-07 2:31 
Questionlinked list problem Pin
neha.agarwal2730-Mar-07 1:33
neha.agarwal2730-Mar-07 1:33 
AnswerRe: linked list problem Pin
Cedric Moonen30-Mar-07 1:44
Cedric Moonen30-Mar-07 1:44 
AnswerRe: linked list problem [modified] Pin
CPallini30-Mar-07 1:59
mveCPallini30-Mar-07 1:59 
GeneralRe: linked list problem Pin
neha.agarwal2730-Mar-07 2:13
neha.agarwal2730-Mar-07 2:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.