|
Well, your making me lose my beauty sleep. And believe me I need it. Perhaps you should read this:
Enabling and Disabling Privileges in C++[^]
Just copy and paste that Microsoft example code into your project. You would use it like this:
BOOL GetYourPermission()
{
HANDLE token = 0;
if(TRUE == OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
{
return SetPrivilege(token, SE_TAKE_OWNERSHIP_NAME, TRUE);
}
return FALSE;
}
Btw, I hope your logged in under the Administrator account.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks. I will have a try.
|
|
|
|
|
I have tried like following code:
int ret = GetYourPrivilege();
HKEY key;
DWORD err = RegCreateKeyEx(HKEY_LOCAL_MACHINE,_T("SYSTEM\\CurrentControlSet\\Enum\\Root\\MYKEY"),
0,NULL,0,KEY_ALL_ACCESS,NULL,&key,NULL);
it still get failed with an error code:ERROR_ACCESS_DENIED
what's wrong? I do logined with admin account.
|
|
|
|
|
I should have explained it better. You need to add yourself to the access control list[^] before you can modify that area of the registry.
INFO: Changing Ownership of a Securable Object[^]
kcynic wrote: DWORD err = RegCreateKeyEx(HKEY_LOCAL_MACHINE,_T("SYSTEM\\CurrentControlSet\\Enum\\Root\\MYKEY"),
Thats a very interesting registry key your attempting to access/write as it controls drivers/filter drivers for system hardware. Are you installing a filter driver or something? That particular registry key can also be used for malware, do you mind me asking why you need to manually modify that registry key? If you are installing a device driver or upper/lower level filter driver then there are better solutions provided for driver installation.
Best Wishes,
-David Delaune
|
|
|
|
|
hehe, it doesn't matter i tell you what i want. I only want to install a lower level filter driver to the system. The driver is provided by a third-party tool. I know how to modify the register to install it and make it work perfectly. I know write a simple .inf install file is suitable, but, the problem is, im not a driver developer with little driver acknowledge. And, i'll read the articles you provided and have a try immediately.
Further more, any further advise is appreciated,too.Thanks.
Regards.
|
|
|
|
|
kcynic wrote:
I know write a simple .inf install file is suitable, but, the problem is, im not a driver developer with little driver acknowledge.
The third party driver developer should have provided an INF file for you. Microsoft provides the Setup API[^] which is designed to make it easier to correctly install device drivers. There is sample code provided at the that URL.
Best Wishes,
-David Delaune
|
|
|
|
|
the problem is that, there is no inf file.
i only know how to modify the reg key
|
|
|
|
|
in worker thread i want to get check focus on items of dialogs i m using this method
UINT CustomThread(LPVOID lParam)
{
{CMthreadDlg *c=(CMthreadDlg*) lParam;
CDC *d=c->GetDC();
CWnd *pWnd=d->GetWindow();
pWnd=c->GetFocus();
if(pWnd->GetDlgCtrlID()==(IDC_BUTTON1))
{
c->GetDlgItem(IDC_TA)->SetWindowText("abc");
}
return 1;
}
using statemnt
pWnd=c->GetFocus() in simple class method properly works but in worker thread its not working so how can i resolve it plz help me.
|
|
|
|
|
|
shaina2231 wrote: in worker thread...
See here.
"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
|
|
|
|
|
Hello,
I wanted to delete a file suppose C:\Appliaction\Contract.csv from my application.Is there any method available?
Thanks
Prithaa
|
|
|
|
|
how about remove, _wremove?
|
|
|
|
|
You can use of SHFileOperation or DeleteFile.
|
|
|
|
|
You could use CFile::Remove() as well.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
I need help with a linked list program, im probably just not doing something write but if any info is available i would greatly appreicate it, here is my code. its suppossed to append a node, insert a node, and delete a node. The output should look like this. Thanks for all help i can get
Here are the initial values:
5 feet, 4 inches
6 feet, 8 inches
8 feet, 9 inches
Now inserting the value 7 feel 2 inches.
Here are the nodes now.
5 feet, 4 inches
6 feet, 8 inches
7 feet, 2 inches
8 feet, 9 inches
Now deleting the last node.
Here are the nodes left.
5 feet, 4 inches
6 feet, 8 inches
7 feet, 2inches
// This program demonstrates the linked list template.
#include "stdafx.h"
#include <iostream>
#include "LinkedList.h"
#include "FeetInches.h"
using namespace std;
int main()
{
// Define a LinkedList object.
LinkedList<feetinches> list;
// Define some FeetInches objects.
FeetInches distance1(5, 4); // 5 feet 4 inches
FeetInches distance2(6, 8); // 6 feet 8 inches
FeetInches distance3(8, 9); // 8 feet 9 inches
// Store the FeetInches objects in the list.
list.appendNode(distance1); // 5 feet 4 inches
list.appendNode(distance2); // 6 feet 8 inches
list.appendNode(distance3); // 8 feet 9 inches
// Display the values in the list.
cout << "Here are the initial values:\n";
list.displayList();
cout << endl;
// Insert another FeetInches object.
cout << "Now inserting the value 7 feet 2 inches.\n";
list.insertNode(distance4); // 7 feet 2 inches
FeetInches distance4(7, 2);
// Display the values in the list.
cout << "Here are the nodes now.\n";
list.displayList();
cout << endl;
// Delete the last node.
cout << "Now deleting the last node.\n";
list.deleteNode(distance4);
// Display the values in the list.
cout << "Here are the nodes left.\n";
list.displayList();
return 0;
}
|
|
|
|
|
I don't know the specifics of your implementation of "LinkedList.h" but here are a couple of quick things to get you started.
You don't ever really "append a node". When you add "7 feet, 2 inches", you are really inserting it (in the middle of your list). You have to find the node you want to add before (just before "8 feet, 9 inches") and then insert your node.
You are inserting distance4 before you create it. You have to create the object first, then insert it.
In your code, you say you are "deleting the last node" but that's not what you are doing. Do are deleting a specific node. To delete the last node, you have to go to the end of the list and then delete that node.
|
|
|
|
|
I'm kind of confused I'm not sure if I know what you mean. I looked in my book and it was the same program and the code in the book.
|
|
|
|
|
Essentially these two lines need to be swapped because you are attempting to insert a variable before it was created.
list.insertNode(distance4);
FeetInches distance4(7, 2);
It is hard to say if there are any other bugs because we cannot see the implementation of LinkedList.h
Best Wishes,
-David Delaune
|
|
|
|
|
What does the implementation of LinkedList look like?
"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
|
|
|
|
|
Here is linked list.h Thanks for all the help by the way. Do you need FeetInches.h also
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include <iostream>
using namespace std;
template <class t="">
class LinkedList
{
public:
struct ListNode
{
T value;
struct ListNode *next;
};
ListNode *head;
public:
LinkedList()
{ head = NULL; }
~LinkedList();
void appendNode(T);
void insertNode(T);
void deleteNode(T);
void displayList() const;
};
template <class t="">
void LinkedList<t>::appendNode(T newValue)
{
ListNode *nodePtr;
newNode = new ListNode;
newNode->value = newValue;
newNode->next = NULL;
if (!head)
head = newNode;
else
{
nodePtr = head;
while (nodePtr->next)
nodePtr = nodePtr->next;
nodePtr->next = newNode;
}
}
template <class t="">
void LinkedList<t>::displayList() const
{
ListNode *nodePtr;
nodePtr = head;
while (nodePtr)
{
cout << nodePtr->value << endl;
nodePtr = nodePtr->next;
}
}
template <class t="">
void LinkedList<t>::insertNode(T newValue)
{
ListNode *newNode;
ListNode *nodePtr;
ListNode *previousNode = NULL;
newNode = new ListNode;
newNode->value = newValue;
if (!head)
{
head = newNode;
newNode->next = NULL;
}
else
{
nodePtr = head;
previousNode = NULL;
while (nodePtr != NULL && nodePtr->value < newValue)
{
previousNode = nodePtr;
nodePtr = nodePtr->next;
}
if (previousNode == NULL)
{
newNode->next = nodePtr;
}
else
{
previousNode->next = newNode;
newNode->next = nodePtr;
}
}
}
template <class t="">
void LinkedList<t>::deleteNode(T searchValue)
{
ListNode *nodePtr;
ListNode *previousNode;
if (!head)
return;
if (head->value == searchValue)
{
nodePtr = head->next;
delete head;
head = nodePtr;
}
else
{
nodePtr = head;
while (nodePtr != NULL && nodePtr->value != searchValue)
{
previousNode = nodePtr;
}
if (nodePtr)
{
previousNode->next = nodePtr->next;
delete nodePtr;
}
}
}
template <class t="">
LinkedList<t>::~LinkedList()
{
ListNode *nodePtr;
ListNode *nextNode;
nodePtr = head;
while (nodePtr != NULL)
{
nextNode = nodePtr->next;
delete nodePtr;
nodePtr = nextNode;
}
}
#endif</t></class></t></class></t></class></t></class></t></class></class></iostream>
|
|
|
|
|
Did you heed Randor's advice?
"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
|
|
|
|
|
yes, and i get the following error messages.
linkedlist.h(47) : error C2065: 'newNode' : undeclared identifier
linkedlist.h(43) : while compiling class template member function 'void LinkedList<t>::appendNode(T)'
with
[
T=FeetInches
]
linkedlistexample.cpp(11) : see reference to class template instantiation 'LinkedList<t>' being compiled
with
[
T=FeetInches
]
linkedlist.h(48) : error C2227: left of '->value' must point to class/struct/union/generic type
linkedlist.h(49) : error C2227: left of '->next' must point to class/struct/union/generic type
|
|
|
|
|
LilKoopa wrote: linkedlist.h(47) : error C2065: 'newNode' : undeclared identifier
The error is self explanatory. On line 47 of linkedlist.h, you are using newNode which has not yet been declared.
"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
|
|
|
|
|
ok now I'm down this one error message and i dont know what i am suppossed to do
error C2244: 'LinkedList<t>::displayList' : unable to match function definition to an existing declaration
|
|
|
|
|
LilKoopa wrote:
error C2244: 'LinkedList::displayList' : unable to match function definition to an existing declaration
So which line is causing this error?
"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
|
|
|
|