|
Thank You Naveen. The linker error has gone.
Is there any other alternative function to get the local system administrator?
Taruni
|
|
|
|
|
Whats wrong with this function?
|
|
|
|
|
I am unable to understand as how to enumerate the users list.
Taruni
|
|
|
|
|
sample code:
LPLOCALGROUP_MEMBERS_INFO_1 pstMembersInfo = 0;
DWORD entriesread = 0;
DWORD totalentries = 0;
if( 0 != NetLocalGroupGetMembers( NULL, _T("Administrators"), 1, (LPBYTE*)&pstMembersInfo,
MAX_PREFERRED_LENGTH, &entriesread, &totalentries, 0 ))
{
AfxMessageBox( _T("NetLocalGroupGetMembers failed !"));
return ;
}
for( DWORD dwIdx =0; dwIdx < entriesread; dwIdx ++ )
{
AfxMessageBox( pstMembersInfo[dwIdx].lgrmi1_name );
}
NetApiBufferFree( pstMembersInfo );
|
|
|
|
|
Thank you Naveen for the great help.
Taruni
|
|
|
|
|
What does that have to do with using another function? Regardless of how the list is obtained, wouldn't you still need to iterate through it?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Taruni wrote: I am getting the linker error "error LNK2001: unresolved external symbol _NetLocalGroupGetMembers@32". Doesn't this header file "lmaccess.h" come with Visual Studio?
Yup sure does, that's why it's a linker error and not a compile error that you're getting.
You'll have to link the netapi32.lib to get access to the function.
Yeah, what Naveen said.
|
|
|
|
|
Is it possible (and a rationale design) to show a menu on right-click of the list box item of a combo box and remove
the item by clicking a menu item say 'Remove Item'.
Any similar help material/article are welcome.
Thanks in Advance.
|
|
|
|
|
|
I was wondering if someone could look at my code and tell me why when i try to get the average of the array it wont give me the average. It compiles, the only problem is the sum and average are the same. here is my code
// LanusArrays.cpp : Defines the entry point for the console application.
// Corey Lanus
// Test 2 Part 2
// Lanus Arrays
// Does a lot of things dealing with arrays.
// October 16, 2006
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
const int ARRAY_SIZE = 20;
int numbers[ARRAY_SIZE];
int count;
ifstream inputFile;
inputFile.open("numbers.txt");
for (count = 0; count < ARRAY_SIZE; count++)
inputFile >> numbers[count];
inputFile.close();
int total = 0;
for (int count = 0; count < ARRAY_SIZE; count++)
total += numbers[count];
cout << "The sum of the numbers is: "<< total << endl;
cout << endl;
double total2 = 0;
double average;
for (int count = 0; count < ARRAY_SIZE; count++)
total2 += numbers[count];
average = total2 / ARRAY_SIZE;
cout << "The average of the numbers is: "<< total2 << endl;
cout << endl;
int highest;
highest = numbers[0];
for (count = 1; count < ARRAY_SIZE; count++)
{
if (numbers[count] > highest)
highest = numbers[count];
}
cout << "The highest number is: " << highest << endl;
cout << endl;
int lowest;
lowest = numbers[0];
for (count = 1; count < ARRAY_SIZE; count++)
{
if (numbers[count] < lowest)
lowest = numbers[count];
}
cout << "The lowest number is: " << lowest << endl;
cout << endl;
cout << "The numbers are: ";
for (count = 0; count < ARRAY_SIZE; count++)
cout << numbers[count] << " ";
cout << endl;
cout << "The numbers are:\n ";
for (count = 0; count < ARRAY_SIZE; count++)
cout << numbers[count] << " \n";
cout << endl;
return 0;
}
|
|
|
|
|
The following code
average = total2 / ARRAY_SIZE;
cout << "The average of the numbers is: "<< total2 << endl;
should be
average = total2 / ARRAY_SIZE;
cout << "The average of the numbers is: "<< average << endl;
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
thanks I cant believe I missed something so small
|
|
|
|
|
When you get all this working the way you want, be sure and check out some of the STL algorithms. They can do a lot of this for you. For educational purposes, it's always nice to do everything yourself (I started this way and am better for it), but just know that standard functions and classes do exist for some things.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I'm doing a project where I've got 4 classes for a database. I've got CRecordSet derived classes for each of the tables I'm interacting with.
Here's an example of two of the tables:
struct part
{
long priKey;
string partDescription;
};
typedef CArray<part, part> MyPartArray;
class CPartsTable : public CRecordSet
{
BOOL AddNew(part& p);
BOOL Edit(part p);
BOOL Delete(part p);
BOOL GetList(MyPartArray& list);
}
struct board
{
long priKey;
long serialNumber;
long mfgId;
};
typedef CArray<board, board> MyBoardArray;
class CBoardTable : public CRecordSet
{
BOOL AddNew(board& p);
BOOL Edit(board p);
BOOL Delete(board p);
BOOL GetList(MyBoardArray& list);
};
I was thinking that it would make my life much easier if I could wrap them in a common interface like so:
class ICommonTable
{
virtual BOOL AddNew()=0;
virtual BOOL Edit()=0;
virtual BOOL Delete()=0;
virtual BOOL GetList()=0;
};
My question at this point is: how do I handle the parameters to the functions when using the interface?
The only thing I could think to do was to create a parameter base class for the part and board to derive from then use the parameter base class for the ICommonTable parameters:
class ICommonParam {}
typedef CArray <ICommonParam*, ICommonParam*> MyCommonArray;
class ICommonTable
{
virtual BOOL AddNew(ICommonParam* pItem)=0;
virtual BOOL Edit(ICommonParam* pItem)=0;
virtual BOOL Delete(ICommonParam* pItem)=0;
virtual BOOL GetList(MyCommonArray& list)=0;
};
My problem is that it seems to make the code more complicated.
Is this strategy a good idea? Should I even try to create a common interface?
If anyone has suggestions I'll gladly take them.
|
|
|
|
|
You could get the inheritance to work by making the interface a template, i.e.
template<typename T>
class ICommonTable
{
virtual BOOL AddNew(T&)=0;
virtual BOOL Edit(T)=0;
virtual BOOL Delete(T)=0;
virtual BOOL GetList(CArray<T,T>&)=0;
};
class CPartsTable : public CRecordSet, ICommonTable<part>
{
...
};
class CBoardTable : public CRecordSet, ICommonTable<board>
{
...
}
This would help if you were writing a lot of generic functions that operated on the tables without needing to know the details (for instance an algorithm that deleted every second entry could be written as a template function and would work on both part and board tables). However without knowing why you think the common interface would make your life easier then it is hard to know whether this would help or not.
Graham
Librarians rule, Ook!
|
|
|
|
|
I have been developing C++ code for many years now, but I am relatively new to MFC. I am going through the book "Programming Windows 95 with MFC" (First Edition) by Jeff Prosise. I have carefully gone through the first seven characters of the book. I also went through all the examples and ran them on my computer with no problems. I have also written three toy MFC applications.
When I get to chapter 8 (which deals with SDI), I cannot get the example to work. I feel that MFC programs written using the SDI model are hard to understand and hard to debug. I do not see the SDI model as a big time saver for the developer. Is it really that good? By the way, if somebody has a small (say under 100 lines) MFC SDI program that they could send me, I would really appreciate it.
The reason I am learning MFC is that I want to write a 1st class Retirement Calculator. Should such a program be written as a SDI application? I am thinking that it should not.
Please comment.
Bob
|
|
|
|
|
The book you've got is really good for learning MFC.
The question I have is: what version of visual studio are you using to run the examples? I found it easy to compile the examples with VC++ 6.0. I think that the newer versions of VC++ will work but you might get some problems.
As far as the need for SDI and MDI applications: you can usually get by just using dialog based apps. However, the SDI apps provide a better design framework. This is especially true if you want to distribute your presentation code from you data handling code. The SDI framework also makes it easy to save your application's data.
One thing that might help you is to try deriving the View class from CFormView. This has the effect of combining the SDI Document/View framework with the ease of Dialog programming. (The App wizard allows you to change the View base class in the last step.)
Good luck
|
|
|
|
|
Can someone give me a example of a assignment statement to compute wages?
|
|
|
|
|
I am going to assume that the person's rate is in the variable rate and that the number of hours
worked is in a varaiable called hours. In addition, I am assuming time and a half after 40.
pay = rate*hours + ( (hours>40) ? (rate*hours/2) : 0 );
Now, there is an issue about the type of the variables. Should they be an integer type or a floating point type. There is also the related issue of rounding. I hope this helps.
Bob
|
|
|
|
|
So if he hours worked is 40, pay rate is 12.75 and the weekly wages = 510. would the assignment statement be:
weekly wages = pay rate*hours worked + ( (hours>;40) ? (12.75*hours/2) : 0 );
Does this make sense.
|
|
|
|
|
You added an extra semicolon, but the statement does make sense. It should be:
weekly wages = 12.75*40 + ( (40>40) ? (12.75*40/2) : 0 );
Now, 12.75*40 = 510 and 40 > 40 is false so we have
weekly wages = 510 + 0
or
weekly wages = 510
Bob
|
|
|
|
|
Last question. Before the statement does it have to be declared?
|
|
|
|
|
I am not sure I understand your question. However, all variables must be declared/defined before use. If you use a variable without declaring it, the compiler will generate a compiler error.
Bob
|
|
|
|
|
I'm sorry for being confusing. Does the assignment statement goes in as a statement like:
//weekly wages = 12.75*40 + ( (40>40) ? (12.75*40/2) : 0 );
modified on Thursday, October 16, 2008 8:53 PM
|
|
|
|
|
It depends on exactly what you want to compute, however, in a word, No. If Weekly wages is suppose to be a variable then you are not allowed to have spaces in the variable.
I get the impression that I am not helping you. I think you need to find a basic tutorail on C or C++ and read it.
Bob
|
|
|
|