|
Alexander M. wrote:
and i want to code a software, to link them runtime! So GetProcAddress will get problems!
What do you mean? Are you having problems accesing the functions with GetProcAddress() now, or do you intend to write functions which cannot be accessible using GetProcAddress()?
--
They're out get me, I can't escape cos' they won't let me
They won't forget me, they'll get me in their grip and sweat me
They'll wait me out, and then move in under my skin
They'll make me doubt, they're out to make me let them in
|
|
|
|
|
Hi,
How can I get the current username from a NT service?
GetUserName() and WNetGetUser() returns allways "SYSTEM"
tx
|
|
|
|
|
it's not that easy as u think!
it is possible, that multiple users are logged on at one machine!
Don't try it, just do it!
|
|
|
|
|
That's because you have configured your service to run under the LocalSystem account and that is in fact the correct username.
Presumably what you want is to find out the username of the whomever is logged onto the interactive console at the time? (Keeping in mind that the answer might be 'no one'.)
A sketch of the solution is as follows:
1) Call OpenWindowStation("WinSta0", FALSE, WINSTA_READATTRIBUTES) to a handle to the interactive WindowStation.
2) Call GetUserObjectInformation(hWinSta, UOI_USER_SID, ...) to get the SID of the user currently logged onto that WindowStation.
3) Call LookupAccountSid(...) to get the username from the SID returned above.
Points to consider:
If you are running on a version of the OS with Terminal Services installed you should start with the WTSEnumerateSessions() first to determine which WindowStation name you care about. This includes WinXP and W2K3 as they use the terminal services infrastructure all the time.
You may not really want the name, for anything security related you should probably be comparing against or logging that SID obtained in step three directly. Usernames can be duplicated between local and domain accounts and can change over the lifetime of an account, SIDs do not.
-Blake
|
|
|
|
|
Using VisualC++ 6.0 SP5 I create a new MFCAppwizard(exe) project named "my". I choose SDI with doc/view architecture support then click finish to leave all other options at their defaults. Since the project is named "my" the classes created are "CMyApp", "CMyDoc", "CMyView", "CMainFrame" and "CAboutDlg". If I build it now it will run fine so far. Then if I include the header for the CMyView class in the cpp for the CMainFrame class like so:
<br />
<br />
#include "stdafx.h"<br />
#include "my.h"<br />
<br />
#include "MainFrm.h"<br />
<br />
#include "myview.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
...<br />
...<br />
...<br />
it does not compile. The 3 errors it gives are really weird:
myprojects\my\myview.h(21) : error C2143: syntax error : missing ';' before '*'
myprojects\my\myview.h(21) : error C2501: 'CMyDoc' : missing storage-class or type specifiers
myprojects\my\myview.h(21) : error C2501: 'GetDocument' : missing storage-class or type specifiers
weird, eh? I noticed that if you move the #include "myview.h" line to the top of the file (i.e. before the other three #include statements) it will compile but if you make reference to anything that was declared in myview.h it will give an error saying "undeclared identifier".
For example if I wanted to create a pointer to a CMyView class within the constructor of the CMainFrame class like so:
<br />
CMainFrame::CMainFrame()<br />
{<br />
CMyView* p;<br />
}<br />
it gives the following error messages:
MyProjects\my\MainFrm.cpp(45) : error C2065: 'CMyView' : undeclared identifier
MyProjects\my\MainFrm.cpp(45) : error C2065: 'p' : undeclared identifier
MyProjects\my\MainFrm.cpp(45) : warning C4552: '*' : operator has no effect; expected operator with side-effect
(remember that is with the #include "myview.h" moved to the very top of the mainfrm.cpp file
anybody know why it doesn't like what I'm trying to do? I'm a bit new at this and I searched the forum for someone asking the same question but didn't find anything relevant.
thanks!
-Oinka
|
|
|
|
|
Oinka wrote:
myprojects\my\myview.h(21) : error C2143: syntax error : missing ';' before '*'
myprojects\my\myview.h(21) : error C2501: 'CMyDoc' : missing storage-class or type specifiers
myprojects\my\myview.h(21) : error C2501: 'GetDocument' : missing storage-class or type specifiers
There are two solutions to this problem.
1. Add #include "MyDoc.h" before the "MyView.h" include
2. Forward declare CMyDoc in the MyView.h header file.
Michael
'Logic, my dear Zoe, merely enables one to be wrong with authority.' - The Doctor: The Wheel in Space
|
|
|
|
|
I tried solution #1 and it works fine now, but I'm still confused about why that is necessary. Why do I have to include the doc class declaration in order to use the view class? Shouldn't the view class header just include everything it needs for itself?
thanks again
-Oinka
|
|
|
|
|
Oinka wrote:
Why do I have to include the doc class declaration in order to use the view class? Shouldn't the view class header just include everything it needs for itself?
The CView derived class has a GetDocument function. I assume there is some MFC design reason why the include file or forward declaration isn't generated by the AppWizard. (Or it could be an oversight by the MFC team not realising how developers were going to structure their code)
Michael
'Logic, my dear Zoe, merely enables one to be wrong with authority.' - The Doctor: The Wheel in Space
|
|
|
|
|
I would really like to find a teacher's version of this book, or an answer guide someplace! Thank you! Alison
------------------------------------
Here's the question: A List ADT is to be extended by the addition of the function SplitLists, which has the following specifications where ListType is either the class UnsortedType or the class SortedType:
SplitLists(ListType list, ItemType iten, ListType& list1, ListType& list2)
----------------------------
Function - Divides list into two lists according to the key of item.
Pre - list has been initialized and is not empty.
Post - list1 contains all the items of list whose keys are less than or equal to item's key. list2 contains all the items of list whose keys are greater than item's key.
----------------------------
a. Implement SplitLists as a member function of the Unsorted List ADT.
b. Implement SplitLists as a member function of the Sorted List ADT.
Also, write a driver program to test your implementation. The driver program should use an Itemtype which contains a single integer value and split the list of numbers (2, 5, 8, 9, 12, 15, 23, 45) on the number 14.
----------------------------
Some direction would really be appreciated. Thanks!
|
|
|
|
|
My best guess:
for part a) I'd say just go through list item by item (since it's unsorted you will have to go through it sequentially). As you go, compare each item in list to item and based on the results of the comparison copy it into either list1 or list2.
for part b) I guess you'd want to binary search list for item then split the list at that point.
|
|
|
|
|
I would really like to find a teacher's version of this book, or an answer guide someplace! Thank you! Alison
------------------------------------
Using one or more stacks, write a code segment to read in a string of characters and determine whether it forms a palindrome. A palindrome is a sequence of characters that reads the same both forward and backward--for example: ABLE WAS I ERE I SAW ELBA.
The character '.' ends the string. Write a message indicating whether the string is a palindrome. You may assume that the data are correct and that the maximum number of characters is 80.
-------------------------------
I'm not sure how to write just a code segment. Not being able to run it leave s me without any direction to go in (knowing if it's right or wrong). Any direction would be appreciated! Thanks!
|
|
|
|
|
aLiSoN3742 wrote:
I'm not sure how to write just a code segment. Not being able to run it leave s me without any direction to go in (knowing if it's right or wrong).
well, just put your code segment in a function , than write a program that passes in a palindrome to function containin the code your testing , and provide a return TRUE or FALSE from that function if its a palindrome or not..
You could test your code segment this way and if you need to just hand in the segment, you take it outta the function once your sure the code works.
or dont even put your code in a function, and hardcode a CString Palindrome = "ABLE WAS I ERE I SAW ELBA"; to act upon in your testing.
aLiSoN3742 wrote:
I would really like to find a teacher's version of this book, or an answer guide someplace! Thank you! Alison
------------------------------------
Using one or more stacks, write a code segment to read in a string of characters and determine whether it forms a palindrome. A palindrome is a sequence of characters that reads the same both forward and backward--for example: ABLE WAS I ERE I SAW ELBA.
The character '.' ends the string. Write a message indicating whether the string is a palindrome. You may assume that the data are correct and that the maximum number of characters is 80.
-------------------------------
i'd help you w/ some code, but as a general rule of thumb, cp'ers dont do other peoples homework. is there anything in particular that is giving you trouble that someone could assist you with? do you have any code written ? the answer 'all of it' doesnt go over well here....
todo....
:: insert inspirational text here ::
|
|
|
|
|
I would say push the first half of the string onto your stack then compare the stack contents to the rest of the string (since the stack contents will be in reverse order - that's just how a stack works).
If they say write a code segment I think it just means write the algorithm and if you need extra code to test the algorithm then don't include that extra test code in your submission.
|
|
|
|
|
Is this an assembly language class?
|
|
|
|
|
Do it on paper first. Get to know the problem. It's not that hard! You will not accomplish anything by asking others to do your homework for you.
I know nothing about you and your current situation. But if you have problems sorting this small problem out, then I suspect you should study something else... or try harder! Hard work has its rewards.
--
They're out get me, I can't escape cos' they won't let me
They won't forget me, they'll get me in their grip and sweat me
They'll wait me out, and then move in under my skin
They'll make me doubt, they're out to make me let them in
|
|
|
|
|
Hi... I'm beginner in C++ and MFC. I'm building an application that interface with a robotic arm... I have already done that part. I'm missing a part where I have a trajectory in (X,Y,Z) and the arm follows the trajectory. I can handle the mathematical stuff to generate the trajectory but I guess I would be nice to have the target trajectory and the real one plotted in the screen. I have somebooks about visual C++ and MFC, but it is hard for me to diggest them.
What I have learnt from the reading is:
1) How to show a window,
What I know I need is:
1) Put the (0,0) in the middle of the window,
2) Draw the X,Y,Z axis (taking care of the scaling)
3) Pass the trajectories generated to be ploted.
However all this, I'm still confused with the MFC and the modes, and the coordinates.
Is there any tutorial that lead me step by step to create an application like that...
I like to follow that by creating a demo application to plot an ellipse. Then, I can pass it over my main application, to plot trajectories (the target and the real) together with the error of a trajectory. Both in a window, trajectories in the top and the error in the bottom. Then, of course I would like to save them and/or printing.
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
|
I am trying to create a time comparison algorithm, and i have had some issues with it. I was wondering if anyone out there has had a problem with this, or if anyone solved this problem. Any help would be appreciated.
-- Steve
|
|
|
|
|
What's a "time-comparison" algo?
bEqual = CompareTime("23:00", "11:00 PM");
Or are you looking for a ready made time-comparison component?
(I do not have the answer, just being noisy)
|
|
|
|
|
I'm trying to create a function similar to your CompareTime(). Basicly, the main issue is telling the difference between say 1:35:59 and say 1:36:05. I need a way for the computer to figure out that there is a 6 second difference between those 2. Once I can figure that out, the rest will be easy.
-- Steve
|
|
|
|
|
you said it yourself, take the "difference" i.e. subtract one time from the other. If they're not in a form that allows arithmetic then convert them to such a form (there must be support for that).
Maybe I'm not understanding your question... it's pretty vague.
|
|
|
|
|
Use mktime() to obtain a time_t value from individual time fields, then use difftime() . Or you can roll your own algorithm like so:
long differenceInSeconds
(long nStartHour,
long nStartMinute,
long nStartSecond,
long nEnd Hour,
long nEndMinute,
long nEndSecond)
{
long nStart = nStartHour*3600 + nStartMinute*60 + nStartSecond;
long nEnd = nEndHour*3600 + nEndMinute*60 + nEndSecond;
return (nEnd - nStart);
} I hope you didn't make me do your homework. (You're only cheating yourself, if you did).
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi !
I am ran into a great problem I can not solve. I need to write a Dial-Up Server project in Win98 by visual c++.
I do followed steps:
1) With TAPI wrote a program that can wait fo call.
2) After client Dial-in (by Dial-up networking),my program answer and connect to client. But problem is here that I can't write the code that build the RADIUS packet for reply to packet that is sent from client.
If could help, please let me know.
A BIG thanks in advance.
|
|
|
|
|
Hi Guys this is very urgent!.
I am tryieng to use extern in my application. I am declaring
extern CAzg a;
and also I have specified header file in include
but I ma getting linkage error.
Can any one solve this and can tell me how to over come this problem.
God Knows Better
|
|
|
|
|
Your project also needs a .cpp file that contains the definition of a , i.e:
CAzg a;
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|