Visual C++ :: Writing To HKLM Registry In Windows 7?
Jul 8, 2013
When I write to the Windows 7 Registry at HKEY_LOCAL_MACHINE, I get a return code of 5 which is the "access denied" message when I execute RegCreateKeyEx.
This happens even if the User has administrator rights.
How can I tell Windows 7 to allow the program to write to the registry?
The application is a 32-bit application and it should be allowed to run in either a Windows 7 32-bit or 64-bit machine.
I noticed that when I run certain popular programs, a User Account Control dialog box comes asking:
"Do if you want to allow the following program from an unknown publisher to make changes to this computer".
Should my application call User Account Control and if so, how do I do it in C++ Visual Studio 2008?
I also found out that 64-bit Windows machines have two registry hives. Is there a different code to handle the same task?
View 8 Replies
ADVERTISEMENT
Feb 19, 2013
I have a 32-bit application that I've been maintaining for about 12 years and it runs on every Windows platform up to Windows 7. In all that time I've been using CWinApp::GetProfileXxxx() and CWinApp::WriteProfileXxxx() calls to read and write my program settings (about 70 settings) in the Registry. The settings are read from the Registry at start-up and written to the Registry when the program closes. There is also a method for the user to read and write the program settings to an INI file using the same code as the Registry access.
On my Windows 7 system the Registry read/write works just like it always has on all previous Windows versions. However, on some customer's Windows 7 machines there appears to be a problem with the Registry access. The program settings are either not being read from the Registry or are not being written to the Registry. I think the settings are not being written - but I don't know that. When the user uses the INI file the settings appear to be read and written.
The customer has complained a bit (I'd complain too) but doesn't have the time or doesn't want to take the time to run some simple tests for me to find out what's going on with his Windows 7 system.
So here is my question: Are there any user account settings or permissions that can block the program's access to the Registry? He claims he is an Administrator but I can't even get him to verify that.
View 5 Replies
View Related
Sep 4, 2014
I'm trying figure out how Windows Firewall functions by experimenting with Bittorrent's add exception to windows firewall option, I deleted the entry from the Firewall options and also located that the regkeys are in HKLM/System/CurrentControlSet/Services/SharedAccess/Parameters/FirewwallPolicy but I can't figure out what registries are made when an application is added as an exception in the Windows Registry.
View 6 Replies
View Related
Jan 18, 2012
I am developing a program that needs auto start at windows startup. For that I need to add Registry entries. Also the program needs to read some registry keys. What are the functions i need to do these.. Simply I need to
check if the startup key already exists
add a new key if it doesn't exist
read a key values
View 7 Replies
View Related
Jan 24, 2014
I'm trying to set up some basic communication between two programs via the registry.
For this I would like to use the functions
Code:
int value=10;
CString strSection="Data";
CWinApp* pApp = AfxGetApp();
pApp->WriteProfileInt(strSection,ValueName,value);
and
Code:
CString strSection="Data";
CWinApp* pApp = AfxGetApp();
int value=pApp->GetProfileInt(strSection,ValueName,0);
which read/write to the application's registry.
Is there some way of making two different programs use the same application registry?
View 14 Replies
View Related
Jan 16, 2013
In a typical MFC application I use SetRegistryKey(_T("My_Company")); to set the root registry entry for my application. The MFC application however creates an entry by the name of executable where it stores all the settings of that application. I don't want that because we often change the name of executable and I want it read registry from the same set location. As example if my application name is Calculator.exe and Calculator_debug.exe it creates two different registry settings.
My_CompanyCalculatorsettings
My_CompanyCalculator_debugsettings.
How can I stop that?
View 1 Replies
View Related
Feb 12, 2013
I have used the following code to attempt to place a binary array into and then retrieve from the Registry. I am a member of the local Administrator group. I have verified that the Registry for the app has a binary array 32 bytes in length under the key "settings" / "keyb" ab 12 cd ...
Code:
// in header
unsigned char m_key[32];
int m_nKeySize;
// in implementation
// int ctor
AfxGetApp()->GetProfileBinary(_T("settings"), _T("keyb"), (LPBYTE*)&m_key, (UINT*)&m_nKeySize);
// in OnDestroy
AfxGetApp()->WriteProfileBinary(_T("settings"), _T("keyb"), (LPBYTE)&m_key, m_nKeySize );
Here is a copy of the binary array in the Registry:
7D DE 2B 30 E7 06 12 AC 99 60 8C 26 21 FC 8E 5B 66 DB 72 9E A2 00 BE 15 E1 8B 67 31 E5 EC 8B 15
Here is the binary key retrieved from the Registry using the code above:
D0 EB 26 00 CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC
View 7 Replies
View Related
Apr 27, 2013
I've just integrated the Windows SDK V7.0A into my VS2005 application, and I'm getting the dreaded "Application configuration error" when I try to run it on an XP machine.
It runs fine on the development machine, and some customer machines (Win7 and Win8), but will not run on XP due to missing/incorrect version dlls.
I've rebuilt all my libraries, but still no joy.
So, my first question is - If I upgrade the Windows SDK to V7.0A, do I also need to use MFC 10 and msvcrt10, or can I stick with MFC 8?
The next question is, how do I find out which dlls are missing, and which libraries or other dlls are requesting the missing versions?
View 11 Replies
View Related
Apr 17, 2013
In my application I have some type of windows showed in an instance of time, and an action shows a new one that i want have the focus all the time , in the way that i can't works with no one of the others. They all are windows, child windows an modeless dialogs, but i don't know how to do. I try use EnableWindow(FALSE) that all the others windows and dialogs, but not works.
View 2 Replies
View Related
Oct 15, 2012
Code:
void CFileMgm::write(string fname, solutions databox) {
file1.open (fname.c_str(), ios::out);
if (file1.is_open())//if(file)+ {
file1<<"Population Size is : ";
file1<<databox.pop_size;
[Code] ....
I don't know why this code is unable to write any thing in file. Following is onsavedocument function
Code:
BOOL CTspGeneticAlgoDoc::OnSaveDocument(LPCTSTR lpszPathName) {
string filename = (string) lpszPathName;
CFileMgm mydatafile;
mydatafile.write(filename,sol);
return CDocument::OnSaveDocument(lpszPathName);
}
View 3 Replies
View Related
Sep 23, 2012
I used to retrieve IP and NIC information by querying windows registry. Now I'm trying to use GetAdapterAddresses() API. Using GetAdapterAddresses() to get IP is not that easy, I need to dig a long deep as I check some examples so far, anyways my question is: Calling this API will return success on all versions of Windows ie: 32bits & 64bits ?
Though Microsoft has not opened any source, where this API is actually retrieving Windows IP information.?. Is it reading Registry or some windows file.
View 6 Replies
View Related
Jul 1, 2013
I want to connect to an SQL Server database using ADO with VC++.
In order to do that you need to import an external dll, like so:
#import "C:Program Files (x86)Common FilesSystemadomsado15.dll"
What if the OS is not 64 bit? That would mean the (x86)-suffix would be incorrect.
how to work around this using certain preprocessor directives?
Something like this, maybe?:
#if 64bit
#import "C:Program Files (x86)Common FilesSystemadomsado15.dll"
#else
#import "C:Program FilesCommon FilesSystemadomsado15.dll"
#endif
View 9 Replies
View Related
Nov 24, 2014
My goal is to know if Windows is installed on an active disk partition.
View 8 Replies
View Related
Apr 21, 2013
I am looking windows slideshow screen saver source code.
View 5 Replies
View Related
Nov 9, 2013
I am new in Visual C++ and I have to make an MFC application with "child" windows. Here is what i need to achieve - [URL] ..... As you can observe when you click on the cross of popup window or child window 2 both are closing.
View 2 Replies
View Related
Jan 23, 2013
I need to compute some values, place them in a structure containing two vector variables, and save them in a CSV file. Right now, I can't even generate a file. I wrote the structure definition and file writing code in a header file (after first borrowing it). I have a "button" that is supposed to trigger all of the activity. I'll attach the code below:
HEADER
________-----_______------
#ifndef EINSTEIN_H
#define EINSTEIN_H
#include <stdio.h>
struct SizeAll{
int year;
double R;
};
int write_to_file(int count, struct SizeAll *data, char const *fileName)
[code].....
My grasp of pointers and how and when to use them evaporated long ago.
View 14 Replies
View Related
Apr 17, 2013
How to write a formula for standard deviation but im having a hard time ?
View 2 Replies
View Related
Oct 6, 2012
I'm trying to learn more about how Lexical Analyzers/Parsers work. I haven't coded any classes yet, because i'm not really sure how the entire process from a Lexer to working code goes.
My goal is to write a simple made up programming language and translate that to another language, like Javascript. The first thing i have to do is give the code to a Lexical Analyzer.
The lexer will split the source into tokens and assign a label to it. So suppose i have the following code:
Code:
def myVar = 10;
The lexer will split that into token like this:
Code:
def -> keyword
myVar -> Identifier
= -> Operator
10 -> Number
That's basically as far as i understand what a lexer does. How can i translate the tokens to a language like Javascript? From what i understand i need to write a Parser class. But i couldn't find any info on what that class exactly does. So what is exactly the next step i have to take?
View 2 Replies
View Related
Jun 26, 2013
I have used the following code to write and read wchar_t bytes from a disk file:
Code:
int WriteBytesW(wchar_t * wcp, int nsz, wchar_t * wcfilepath) {
wfstream wf;
codecvt_utf16<wchar_t, 0x10ffff, little_endian> ccvt(1);
locale wloc(wf.getloc(), &ccvt);
wf.imbue(wloc);
[Code] ....
Output:
save bytes succeeded
1234 5678 9ABC EF12 ABCD FE21 DCBA 1F2A EFFF 02FF
read bytes succeeded
nsz =: 20
Now, if wbuf[8] = 0xefff; is replaced by wbuf[8] = 0xffff;
Output:
save bytes succeeded
1234 5678 9ABC EF12 ABCD FE21 DCBA 1F2A 02FF
read bytes succeeded
nsz =: 18
Obviously, the 0xffff wbyte is not read. WHY ?
This presents a significant problem when attempting to read ALL wbytes from a file.
View 9 Replies
View Related
Feb 3, 2013
I designed an app for work that lets you enter data in a much more efficient way, then it needs to paste this data into the very curmudgeonly interface we use for work. I designed this app a long time ago while at a different company, and I used VC++ 6. I'm still using VC++ 6, but in a vbox with windows XP.
The code is being called as part of a bigger function that determines what exactly needs to be pasted into the work app spreadsheet. I have to call each item separately because the work app does not take copied tabs the way Excel would or whatever, it just ignores them. And it also pops up boxes and such that need to be handled in other ways.
The result works just fine under Windows XP, but when I do it under my regular Win7 box or on the Win7 boxes at work, it does not work properly.
This sets the data up, Text being the data to be pasted:
Code:
while (1) {
if (OpenClipboard() == FALSE) {
::Sleep(1);
continue;
}
HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
[Code] ....
No infinite loops yet, again was just testing if it was OpenClipboard failing because it was being called again too quickly or something (and it did happen occasionally).
Then testing that the clipboard data is correct (this is always true), and pasting with keybd_event. SendInput is not available with VC++ 6.
Code:
HGLOBAL hglb;
LPTSTR lptstr;
LPTSTR buf = Text.GetBuffer(0);
while (OpenClipboard() == FALSE)
::Sleep(1);
[Code] .....
If the ::Sleeps are commented out, it will paste the wrong data almost every time under win7. It seems like it pretty much uses the last thing to be copied in the function and pastes it over and over (but not *always*). If I uncomment them, it will work as expected, but it obviously takes longer. With ::Sleep(50), it works about 80-90% of the time. Obviously I can't have the wrong data being pasted, and I'd prefer not to have to wait like this--and perhaps on a slower system or a system that is doing other things it may take longer and paste the wrong thing. It works fine on XP even without the sleeps.
Did keybd_event become a separate thread or something? Am I doing something wrong with the buffers? (I've tried using CSharedFile too with GMEM_MOVEABLE | GMEM_SHARE | GMEM_ZEROINIT settings, exact same thing.) Why does it work fine under XP but not under 7?
View 10 Replies
View Related
Jan 28, 2013
The following code it taken from msdn library but it is failing to compile.
the following code has a header where all the variables used here are stored in header App.h.
The following lines are giving trouble:
Code:
DialogBox(pApp->getInstance(), MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, pApp->About);
error: 'App::About': function call missing argument list; use '&App::About' to create a pointer to member
Code:
wcex.lpfnWndProc= &App::WndProc;
error: '=' : cannot convert from 'LRESULT (__stdcall App::* )(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'
There is no context in which this conversion is possible
Here is the complete code:
#include "stdafx.h"
#include "App.h"
App::App(void) {
}
App::~App(void) {
[Code] .....
View 4 Replies
View Related
Oct 31, 2014
Is it possible to show a console window in a Win32 DLL?
View 3 Replies
View Related
Jan 26, 2013
I have struggled to send email from my MFC applications using severl methods:
1) http via my server - works but limited
2) M$ Outlook automation - works but not easily interchangeable between machines
3) Windows Sockets - available information simply too complicated
4) Purchase an ActiveX control - I hate black box solutions and am too cheap
I have looked at P. J. Naughter's class
CPJNSMTPConnection v2.99
An MFC class to encapsulate the SMTP protocol
[URL]
This approach requires the implementation of OpenSSL which turns out to be nothing short of a nightmare to install (so I never got it to run). I am looking for an example of an application that utilizes SMTP via Windows sockets api.
View 6 Replies
View Related
Aug 4, 2013
I have created an application to burn my data files into DVD. The problem which I am facing is as follows:
Suppose I have a folder "Doc_Files" present inside "D:Data" location for burning into DVD. The correct behaviour of the application is, after writing the "Doc_Files" folder into disc, I have to immediately delete this "Doc_Files" folder from the "D:Data" location.
I am calling the DeleteFile() Win32 API for deleting those files which are present inside "Doc_Files" folder.
The files are getting deleted successfully but they are still shown in the same folder untill I do not terminate the application.
Till the application is up those files are still visible even after they are deleted. And as soon as I kill my application and refresh my data folder those files are gone, and the folder becomes empty.
I am making use of IMAPI interfaces and methods for burning process.
View 3 Replies
View Related
Apr 10, 2013
I want to do conditional compilation based on whether it is windows 7 or windows 8. Here is the code below.
#if (_WIN32_WINNT >= 0x0602) //Condition to check whether it windows 7 or 8 .Based on this we can load msxml 3 or 6.
#import <msxml6.dll>
#else
#import <msxml3.dll>
#endif
Im building the above code in windows 8 machine.
Issue here is _WIN32_WINNT should have a value 0x0602, it means it is running in windows 8 machine.Instead it has a value 0x0601 (Means it is taking windows version as windows 7 defined in sdkddkver.h).Im not sure after installing windows 8 sdk im not able to see any include or lib files in the path below C:Program Files (x86)Microsoft SDKsWindowsv8.0A . but i can see all include and lib files of sdk version v7.0A available although i did not installed it.
View 5 Replies
View Related
Feb 25, 2015
I'm Getting exceptions on Windows 7 and Windows 8 on different parts of the Code? Why this can be happening, why the difference in behavior?
View 6 Replies
View Related