|
ani_ikram wrote: is there some way to check status of printer...
What about calling GetPrinter(hPrinter, 2, ...) ?
"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
|
|
|
|
|
Hi all,
My reqirement is to change admin rights user to limited account user. I tried to change admin rights to limited user account using NetUserSetInfo(). But wasnt succeeded in that.
so please help me out in this scenario. How would I accomplish it?? Any help would be greatly appreciated.
Thanks.
Hemang
|
|
|
|
|
Hemang Raval wrote: I tried to change admin rights to limited user account using NetUserSetInfo(). But wasnt succeeded in that.
What did NetUserSetInfo() return?
"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
|
|
|
|
|
It has returned error code 87. Having been referred to MSDN, i came to know that this error code indicates that one of the functions parameter is invalid. But i am not having an idea about which parameter i am passing wrong.
Any clue?? Your help would be greatly appreciated.
Thanks
Hemang
|
|
|
|
|
|
void ChangeUserPrivilege(LPWSTR csUser, DWORD csPrivilege)
{
NET_API_STATUS nStatus;
USER_INFO_1 ui1005;
DWORD dwLevel1005 = 1005;
DWORD dwPrivilege = 0;;
wchar_t *pswzUser = csUser;
if(csPrivilege == 2) dwPrivilege = USER_PRIV_USER;
ui1005.usri1_priv = dwPrivilege;
nStatus = NetUserSetInfo(NULL,pswzUser,dwLevel1005,(LPBYTE)&ui1005,NULL);
if(nStatus != NERR_Success)
// MessageBox(hwnd, (LPCWSTR)"Failed", (LPCWSTR)"Test", NULL);
fprintf(stderr, "NetUserGetinfo failed with error: %d\n", nStatus);
}
I am using above code to change admin rights user to limited rights user. Is it possible with this code.
Thanks
|
|
|
|
|
Hi
I need to get the name of the local system Administrator (System is in the domain). As that name however appears in the ControlPanel->"UserAccounts" list or ControlPanel->AdministrativeTools->ComputerManagement->LocalUser and Groups->Groups and clicking on "Administrators" Group, I am trying to list out all the users under "Administrators" Group and for this purpose I am using NetLocalGroupGetMembers() and including lmaccess.h file. But I am getting the linker error "error LNK2001: unresolved external symbol _NetLocalGroupGetMembers@32". Doesn't this header file "lmaccess.h" come with Visual Studio?
Using ADSI, I can get the members of an "Administrators" group (local system) , however, that list doesn't include the name of the the local system administrator , who is a member in the domain.
Is there anyother alternative mechanism/function to get the local system Administrator Name?
Thanks in Advance.
Taruni
|
|
|
|
|
You need to add Netapi32.lib to your project.
If you are using VS6, take
project settings->Link Tab and in that you can find a edit box "Object/library modules". Enter Netapi32.lib in it.
|
|
|
|
|
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
|
|
|
|