|
Sometime the order that you #include header files will cause stuff like this to happen because one header expects another to be included first. Try changing the order of your #include s.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
I used the class to obtain values that an installer package saved to the registry. I can see the values in Regedit. but when the CRegistry class (readline()) never reads them!
I really need a solution to this: here's my code:
// App command to run the dialog
void CShopApp::FindRegData()
{
CRegistry Reg();
CRegData m_cRegData;// class of 5 CStrings
m_cRegData.CleanUp();
//CRegistry Reg;
CString csSubRoot = "SOFTWARE\\Mills Software Solutions Inc\\Shop";
m_cRegData.m_csRootMainKey = "HKEY_LOCAL_MACHINE";
m_cRegData.m_csSubKey = csSubRoot;
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
if (Reg.SetKey(csSubRoot, FALSE))// jumps out here
{
m_cRegData.m_csCompany = Reg.ReadString("Company", "");// all CStrings in class m_cRegData are
"bad pointer" errors
m_cRegData.m_csUser = Reg.ReadString("Name", "");
m_cRegData.m_csSerialCode = Reg.ReadString("Serial", "");
m_cRegData.m_csRegCode = Reg.ReadString("RegCode", "");
//Reg
}
else
{
TRACE("Failed to open key\n");
}
m_csSaveData = InsertDelimiterReg(m_cRegData);// all CStrings Bad pointer
FileSaveRegData();
}
Can someone please explain why this is happening? I used REGEDIT and found that the key and values are there! I just can't get CRegistry to retrieve them.
Help!
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: I used the class...
This one?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I found the culprit. ERROR_ACCESS_DENIED (Error # 5). How do I tell my program to "Run As Administrator" PROGRAMMATICALLY, without the User having to do anything IN MFC!
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: How do I tell my program to "Run As Administrator" PROGRAMMATICALLY, without the User having to do anything...
Have you looked at AdjustTokenPrivileges() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Old Thread, but I had the same problem with CRegistry class in Windows 7. But my compiled Program didn`t have the problem, so I just activated the "Run as Administrator" option for my Visual Studio, and CRegistry could read the Registry Keys...
|
|
|
|
|
My object is to find the size of the text file without traversing the characters. I wrote the following code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
main()
{
int lno=1,n=0,x=2;
long position=0;
char ch[1000],s[1000];
FILE*fp;
fp=fopen("imp.txt","r");
if (fp==NULL)
{puts("Cannot open file");
exit(1);}
printf("01 ");
while(1)
{
ch[n]=fgetc(fp);
n=n+1;
if (ch[n-1]==EOF)
break;
if (ch[n-1]=='\n')
{printf("\n0%d ",x);
x=x+1;}
else if (ch[n-1]!='\r')
{
printf("%c",ch[n-1]);}
else if (ch[n-1]=='\r')
{continue;}
}
fseek(fp,0,SEEK_END);
position=ftell(fp);
printf("\n\n Size of the text file is %ld bytes\n ",position);
fclose(fp);
}
FILE DATA:
Hello
Roger here
Keep it up
Please reply
The size given by this code is 43 bytes while what i am getting on my windows is 638 bytes. Is this right? If yes then Why?
|
|
|
|
|
Suggestion: Please select your code and click on codeblock while you are posting big code snippets.
please edit it atleast now.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Razanust wrote: FILE*fp;
fp=fopen("imp.txt","r");
Razanust wrote: fseek(fp,0,SEEK_END);
position=ftell(fp);
That is all that is needed to get the size of the file.
Or you can use the CreateFile[^] and GetFileSize[^] APIs.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
hai all,
in one of my applications, i have to automate a dos level command.
so i construct the command into an str and execute it using system(str).
but in this case, the console window is getting flashed while the command is being executed.
could any one suggest any other alternative to avoid the display of console.
thanks in advance.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Hello,
Is it a Windowed application or a console application? Which dos level command are you executing?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
my application is windowed.
actually, there are some Third party command mode tools which should be used in a sequence to perform some operations on wav files and text ifles.
so i wanted to automate them using a single button click.
and each of those tools print some output also, and i have to process and display that output also.
as of now, iam achieving that by redirecting the output to a text file and reading it back.
i would be pleased if you can suggest any easier method also.
bu my immediate problem is to hide or suppress the console window.
if my questin is not clear please let me know. i will try to explain it better.
thank you.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
|
Rajesh R Subramanian wrote: So, you are not working with any DOS commands.
no the sequence of command which i was talking about may also have them.
Yes, i tried to use the create process. but..
CString str;
str.Format("copy database\\*.* %s>>c:\\output.txt",tempfolder);
DeleteFile("output.txt");
STARTUPINFO s;
s.wShowWindow=STARTF_USESHOWWINDOW&&SW_SHOW ;
int ret=CreateProcess(str.GetBuffer(str.GetLength()),NULL,NULL,NULL,NULL,NULL,NULL,NULL,&s,NULL);
there is no result.
what is the mistake here.
|
|
|
|
|
chandu004 wrote: STARTUPINFO s;
s.wShowWindow=STARTF_USESHOWWINDOW&&SW_SHOW ;
s.dwFlags = STARTF_USESHOWWINDOW;
s.wShowWindow = SW_SHOW;
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
no difference still
iam using it this way.
STARTUPINFO s;
s.dwFlags=STARTF_USESHOWWINDOW;
s.wShowWindow=SW_SHOW ;
int ret=CreateProcess(str,NULL,NULL,NULL,NULL,NULL,NULL,NULL,&s,NULL);
here, str contains the command to be executed.
which is working perfectly when i use it with system().
what is the mistake here?
|
|
|
|
|
Try this.
STARTUPINFO si;
PROCESS_INFORMATION pi;
::SecureZeroMemory(&si, sizeof(STARTUPINFO));
::SecureZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
::CreateProcess(NULL, str, NULL, NULL, NULL, NULL, NULL, NULL, &si, &pi);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
securezeromemory undeclared identifier.
this is how the vc++6.0 bangs me. though i included winbase.h.
here i will try to simplify my problem.
say,
str="dir >>c:\\output.txt";
now i want this command to be executed .
can we work in this direction?
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Use memset instead.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
chandu004 wrote: what is the mistake here.
The "mistake" is that you are not using SHFileOperation() to copy the folder contents.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
thanks for your reply.
can you pleaase explain me how and where to use this function?
thanks in advance.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
chandu004 wrote: can you pleaase explain me how and where to use this function?
See here and here and here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Rajesh R Subramanian wrote:
Redirecting an arbitrary Console's Input/Output[^]
dear rajesh,
this seems to be a perfect source match for my type of requirement.
today iam planning to integrate this feature into my app.
but i found it in vs 2008. i have to use it in vc 6.0.
i will try it and come here if iam facing any problems.
many more thanks again.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
You can hide the console if you use CreateProcess by setting the STARTF_USESHOWWINDOW flag and SW_HIDE in the wShowwindow members of the STARTUPINFO parameter. By I don't think you can run an internal DOS command using CreateProcess.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
«_Superman_» wrote: You can hide the console if you use CreateProcess by setting the STARTF_USESHOWWINDOW flag and SW_HIDE in the wShowwindow members of the STARTUPINFO parameter
oh thank you. i will try it now.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|