|
Hi All,,
I know this quetion little much non related to this forum but I found that this is much related to VC++, so I am asking for this problem's suggetion.
I am making Windows Service with help Visual Studio Windows Services Template. And as per my knowledge it uses .Net Framework.I am new at .Net Framework.
My problem is that I want to get user logon- logoff event into my service.So I decided to use LsaEnumerateLogonSessions function.For that I found that I have to use secur32.dll in my application.But how can I include this .DLL into my windows service project.So I don't know how to include this .dll into .Net Framework. Or is there any other way to use this functions into my Service application??
Thanks in Advance.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
I found from googled that we can use below staments to include this .dll and to use this function.
<br />
[DllImport ( "Secur32")] <br />
<br />
private static extern int LsaEnumerateLogonSessions(IntPtr LogonSessionCount, IntPtr LogonSessionList); private static extern int LsaEnumerateLogonSessions (IntPtr LogonSessionCount, IntPtr LogonSessionList); <br />
<br />
But I want similler to work with VC++ windows service project.
Plz help me. I have stucked into this problem.
Thanks.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
Still not getting reply from your side!!!!!!
Ok let me explore something more that what I have tried that you can understand more in this problem.
I include #include Ntsecapi.h file into my .h file (where I want to use this functions) and I try to use this function like below.but it gives me the errors as I going to show....
<br />
PULONG count;<br />
PLUID *luidptr;<br />
LsaEnumerateLogonSessions(count,luidptr);<br />
I got the errors using this function like below...
<br />
<br />
error LNK2028: unresolved token (0A000009) "extern "C" long __stdcall LsaEnumerateLogonSessions(unsigned long *,struct _LUID * *)" (?LsaEnumerateLogonSessions@@$$J18YGJPAKPAPAU_LUID@@@Z) referenced in function "public: void __clrcall CUserInfo::OnCreate(void)" (?OnCreate@CUserInfo@@$$FQ$AAMXXZ)<br />
<br />
error LNK2019: unresolved external symbol "extern "C" long __stdcall LsaEnumerateLogonSessions(unsigned long *,struct _LUID * *)" (?LsaEnumerateLogonSessions@@$$J18YGJPAKPAPAU_LUID@@@Z) referenced in function "public: void __clrcall CUserInfo::OnCreate(void)" (?OnCreate@CUserInfo@@$$FQ$AAMXXZ)<br />
<br />
fatal error LNK1120: 2 unresolved externals<br />
Plz help me. I am confused with problem.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
Have you added Secur32.lib in dependencies of the project?
Project Properties > Linker > Input > Additional Dependancies (in VS2k3)
|
|
|
|
|
Thank very much for reply.
I included that library just a minute ago you replied and it works fine.
I will contact you if I will got any problem in future.
Once again thanks.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
dear all
what happened if the case occurred below? how to correct? thanks
fatal error C1083: Cannot open include file: 'stdlib': No such file or directory
Li Zhiyuan
2/1/2008
|
|
|
|
|
You missed the point (and the following 'h').
Change
#include <stdlib>
to
#include <stdlib.h>
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Can you show your code for header file?
|
|
|
|
|
yes, right, i always think "libaray.h"and <library>, no .h. but actually i use fith edition of c++, it is also available for <clibrary>,thanks a lot.
Li Zhiyuan
3/1/2008
|
|
|
|
|
dear all
how to create a matrix for example 3x4 using c++ as soon as possible? thanks in advance.
sincerely
Zhiyuan
2/01/2008
modified on Tuesday, January 01, 2008 11:16:23 PM
|
|
|
|
|
You mean array of integers?
Then, int a[3][4];
|
|
|
|
|
how to create random real number matrix 3x4?thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
li zhiyuan wrote: random real number matrix
I didnt get you...
You mean elements as real numbers?
If so float a[3][4];
And for getting random numebrs you can use rand(). But it is returning integer values. So you have to convert it to real. For example,
float f = ( rand() % 1000 ) / 1000;
|
|
|
|
|
NS17 wrote: float f = ( rand() % 1000 ) / 1000; // random number between 0 and 1
the above always evaluates to
float f = 0;
Moreover, the best way to produce statistically meaningful random values inside a range is (see http://msdn2.microsoft.com/en-us/library/398ax69y.aspx[^])
int u = (double)rand() / (RAND_MAX + 1) * (range_max - range_min) + range_min;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: the above always evaluates to
float f = 0;
Yes. I forgot about the casting...
It has to be
float f = ( rand() % 1000 ) / 1000.0;
|
|
|
|
|
for instance:
const double MIN_RANGE = 3.0;
const double MAX_RANGE = 1200.0;
int i,j;
double m[3][4];
for (i=0; i<3; i++)
{
for (j=0; j<4; j++)
{
m[i][j] = (double)rand() / (RAND_MAX + 1) * (MAX_RANGE - MIN_RANGE) + MIN_RANGE;
}
}
see MSDN http://msdn2.microsoft.com/en-us/library/398ax69y.aspx[^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: m[i][j] = (double)rand() / (RAND_MAX + 1) * (MAX_RANGE - MIN_RANGE) + MIN_RANGE;
why (RAND_MAX + 1) is needed?
|
|
|
|
|
const double MIN_RANGE = 3.0;
const double MAX_RANGE = 1200.0;
// change the range to fit your needs, of course keep MAX_RANGE > MIN_RANGE
int i,j;
double m[3][4];
for (i=0; i<3; i++)
{ for (j=0; j<4; j++)
{ m[i][j] = (double)rand() / (RAND_MAX + 1) * (MAX_RANGE - MIN_RANGE) + MIN_RANGE;
}
}
however i couldn't get m=3x4 matrix yet, please can give me detail..i did in IDE.
the reslut is 0013fecc..
thanks a lot
Li Zhiyuan
3/1/2008
|
|
|
|
|
Hi,
I am mainframe programmer as such its been really difficult to make the transition to OO way of thinking anyway....
I have a table or a structure which I would like to make dynamic
meaning I can add an entry to it and just re-compile and re-build it
IS DLL export/import they way to go meaning when I define the structure add dllexport to the defination
and make the structure a DLL and get the address of the table with GetProcAddress
Thankx
|
|
|
|
|
1. Lets say I have a MFC SDI with a dialog containing 5 edit boxes.
2. I want to left click on any of the five edits and generate "Hello" in it.
3. I have reached the point where I can click anywhere on the dialog and generate "Hello" into one single edit box.
4. I haven't figured out how to determine if the click is in one of the edit boxes rather than anywhere in the dialog.
5. Then I need to know which edit box.
So, I need advice on #4 and #5. Here is what I have:
CTest.h
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
CTest.cpp
BEGIN_MESSAGE_MAP(CTest, CDialog)<br />
ON_WM_LBUTTONDOWN()<br />
END_MESSAGE_MAP()<br />
...<br />
void CTest::OnLButtonDown(UINT nFlags, CPoint point) <br />
{ <br />
CDialog::OnLButtonDown(nFlags, point);
GetDlgItem(IDC_EDIT_C1L1)->SetWindowText("Hello");
}
Thanks
modified on Tuesday, January 01, 2008 7:07:59 PM
|
|
|
|
|
Try as follows...
BOOL CTestDlg::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_LBUTTONDOWN )
{
if(( pMsg->hwnd == GetDlgItem( IDC_EDIT1 )->m_hWnd ) ||
( pMsg->hwnd == GetDlgItem( IDC_EDIT2 )->m_hWnd ))
{
::SetWindowText( pMsg->hwnd, "Hello" );
}
}
return CDialog::PreTranslateMessage(pMsg);
}
|
|
|
|
|
When you click on an edit control, the message goes to the
edit control window, not to the dialog window.
You could derive a class from CEdit and use that class to
subclass the edit controls. When your CEdit-derived class gets a
WM_LBUTTONDOWN message, it could notify its parent by posting an
app-specific message.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all
please how i can convert integer number to string text like this
(i entered 7 in keyboard and the output will be seven)
thank's for all
-*-*-*-*-*-*-*-*-*
To Be Or Not To Be
(KARFER)
-*-*-*-*-*-*-*-*-*
|
|
|
|
|
you may use the function sprintf function, for instance
int i;
char buffer[20];
i=7;
sprintf(buffer,"%d", i);
or, if you prefer the CString class
int i;
CString str;
i=7;
str.Format("%d", i);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
O.K
Thank's For all
I'll Be There
|
|
|
|