|
Hi All,
Im creating a dll and I want to put in the code a way to create a registry key. Im only trying to do something very simple - (1) Create a registry key & (2) Have a vaule pointing to the root of c:\
Ive just tried the basic regcreatekeyex method and although it compiles it does not actually create anything and I think ive missed something very fundamental here (please forgive the noobie status). Here is the code:
DWORD dwRes, dwDisposition;
SECURITY_ATTRIBUTES sa;
LONG lRes;
HKEY hkSub = NULL;
lRes = RegCreateKeyEx(HKEY_CURRENT_USER, "mykey", 0, "", 0,
KEY_READ | KEY_WRITE, &sa, &hkSub, &dwDisposition);
It compiles fine but when i run regedit and try to find "mykey" it comes up with nothing. Any help would be greatly appreciated. Thanks
Nic
|
|
|
|
|
try:
lRes = RegCreateKeyEx(HKEY_CURRENT_USER, "mykey", 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &hkSub, &dwDisposition);
Since you don^t fill the security attributes struct, passing a NULL pointer should do what you want. Same with classname.....
Greetings,
Davy
|
|
|
|
|
Hi guys
I've got an SDI app and from the view I call a dialog like this.
In CMyView.cpp
void CMyView::OpenMydialog()
{
CMyDialog dlg;
dlg.SetFather(this);
dlg.DoModal();
}
and in my dialog I do this
In MyDialog.h
class CMyView;
CMyView *m_pFather;
void SetFather(CMyView *p_pFather);
and in MyDialog.cpp
#include "myappView.h" (but due to this I have to include first myappDoc.h")
void CMyDialog::SetFather(CMyView *p_pFather) {
m_pFather=p_pFather;
}
What's the usual (and right) way to acces the parent (View) class without to add all these includes?
Now each time I compile , practically all app is compiled again and that's what I want to avoid.
Thanks in forwarding
Doc
|
|
|
|
|
void CMyView::OpenMydialog()
{
CMyDialog dlg(this);
dlg.DoModal();
}
//if you wonna get the parent in your dlg class
void CMyDialog::AMethod()
{
//get the parent
CWnd* pWnd = GetParent();
//you can also cast offcourse, but then you^ll need to include the MyView.h in the MyDialog.cpp:
CMyView* pMyView = (CMyView*)GetParent();
}
Hope this helps you,
Greetings,
Davy
|
|
|
|
|
The problem is that if I follow your example I don't have access to the view variables.
If I have a member called m_nCalls in my view
How do I access to it?
If I do
CWnd* pWnd = GetParent();
pWnd->m_nCalls
I receive compiling a nice
error C2039: 'm_nCalls' : is not a member of 'CWnd'
Doc
|
|
|
|
|
If you want to access members of your view class you`ll need to cast....
CMyView *pMyView = (CMyView*)GetParent();
pMyView->m_nCalls = 2;
don^t forget to do an
#include "MyView.h" in your MyDialog.cpp file then..
Greetings,
Davy
|
|
|
|
|
Another - more "correct" object oriented method - would be to pass the view's pointer to the dialog's constructor (as another poster pointed out). Then when the dialog needs to communicate with the view it would do so via messaging as opposed to directly accessing the view's members, which is an obvious OOP no-no
Cheers,
Tom Archer - Archer Consulting Group
"Eat your brussel sprouts, Junior. There are starving Chinese children American programmers that would kill for that food!"
|
|
|
|
|
Hi
I want to read an Excel File from my C++ component without using
MFC.It is v. easy doing from VB. I create a ref. to MS Excel 10.0
object library and use the workbook.
Please let me know how to achieve the same using C++.
Thanks,
Radix
|
|
|
|
|
AnuradhaCpp wrote:
I create a ref. to MS Excel 10.0
object library and use the workbook.
You can do the same with C++. See the MSDN article Q178749 for an example.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I am writing a project of ListView . I want to show the Application's Icon in
the Local disk when the ListView initializing.
Although I use the follow way:
CImageList m_img;
SHFILEINFO sfi;
::SHGetFileInfo(_T("C:\Program file\"),//I want to read all the
//Application's ICON under the directory
FILE_ATTRIBUTE_NORMAL,
&sfi,
sizeof(sfi),
SHGFI_DISPLAYNAME | SHGFI_ICON);
m_img.create(32,32,TRUE | COLOR8,1,100);
m_img.Add(sfi.hIcon);
GetListCtrl().SetImageList(&m_img);
but I wonder that why the ListView can not show the Application's icon?
Do you know this is why?
Can you tell me if you me ?
Or Give me a example if you have similar project.
Thank you very much!
|
|
|
|
|
Hi.
A piece of software I have been working on relies on the locking and unlocking of 1 byte inside a specified file, from within a thread that is controlled via mutexes.
The problem I am having is intermittent. Occasionally while the following code is called:
TRY
{
m_File.Flush ();
m_File.UnlockRange ( LOCK_BYTE, 1);
}
CATCH (CFileException, e)
{
e->ReportError ();
e->Delete ();
}
END_CATCH
An exception is returned and the exception puts up on the screen "An unknown error occured while accessing an unnamed file" and in the output window "CFile exception: generic, File Unknown, OS error information = 158".
Looking at the values in the CFile object, everything looks fine. Valid handle and valid values in the variables.
Just wondering if anyone has some clue on where to look, what to look for, or even how to fix. Any ideas are welcomed as deadline is fast approaching.
|
|
|
|
|
I am not interested in writing an application which send a hello world program to the users on internet.
If you guys have ever heard of computer worm , then this is my point.I just want to work on the issue of spreading a worm with the payload in the form of a message box , take a not, message box containing a message "HELLO".You guys tell me how and what should be done or any reference of website of anypiece of code which you can refer which tells or helps me in the reproduction process of worm.
Desparately seeking help.
|
|
|
|
|
You want us to help you write a worm ? Brilliant.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
You want us to help you write a worm ? Brilliant.
Plus He is putting his Query about making virus On LEGAL MS partner Site!
This guy got lot of Guts!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
|
Michael Dunn wrote:
To quote Gorilla Monsoon: More guts than brains
What About Stone Cold Steve Austin!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I being a student of Bachelor of computer sciences has got the project of working on the spreading mechanism of computer worm.My aim is to understand the spreading mechanism and not to do and harm and i do mean it.So if anyone can please guide and help me , i would be much grateful.
Regards.
|
|
|
|
|
Now, how would we distinguish this request from the request of a hacker ? Perhaps the best way is that a Bachelor of Computer Sciences would be more likely to be able to work this stuff out for himself ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
It means no help for a computer student from a forum which is very famous world wide.Just to prove that i am a student , i want to say that i didn't any clue about spreading of computer worm from the Giant Black Book on computer viruses (second edition) which i got from hell of difficulty.
Thanks.
|
|
|
|
|
Here's something worth considering. What makes you think that I know how to write a worm ? Not to mention, if I did know, why would I tell someone I don't know, unless I don't care if they use the information for destructive purposes. What you're asking is basically dodgy, no matter which way you look at it.
I'd suggest you need to inhabit some rather shadier places if you want to know how to write destructive code, even if don't intend to use it destructively.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Lets assume for a moment that what you claim is true; that you are only interested in learning this form of coding and no malicious harm intended.
The fact of the matter is that there is no way of creating a 'harm-free' and 'cautious' worm. Its main purpose is to spread. It may not be created to create havoc, but that might very well be the eventual effect. I recall a few self-replicating 'worms' a few years back that brought a few servers down because of this, even though it did nothing destructive in itself.
At worst it will cause serious damage, but it will at least be a very irritating problem for others that are 'infected'. And there is the small thing that you may very well be prosecuted in certain countries if your 'worm' is very successful!
I think it is very clear what others have implied (by their nature of the replies), that what you are considering is a bad idea. I think this is one programming concept that should be kept in the text book only.
I Dream of Absolute Zero
|
|
|
|
|
I HAVE A LITTLE WORM. HIS NAME IS ALBERT, HE LIVES IN MY GARDEN, I CAN SEND U SOME PICS IF U WANT
|
|
|
|
|
How to refresh Explorer window after Registry key changed?
I want to hide the files that have hide attribe so I set
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"Hidden" to 0
But that doesn't affect the current opened explorer window. I have to use "refresh" menu (not F5 button) to command to hide the hidden files.
How to tell the current opened explorer window to hide these hidden files after I set the registry key?
Thanks a lot!
Let's roll!
|
|
|
|
|
|
Anyone know of a workaround to force the Visual Studio 6.0 editor to Copy and Paste OEM font characters correctly without translating them through ANSI?
(It correctly saves the text using CF_OEMTEXT flag, as it can be safely pasted into other editors like Codewright, but it apparently decides to convert it when it is pasted - an annoying "feature" that no other editor seems to display.)
gjr
|
|
|
|