Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My guess is that you are calling RegCloseKey() between those two function calls. Here's a non-template version that works

#include <Windows.h>
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::string;

BOOL ShowError(long dwError)
{
    char buf[255]= {0};
    if( dwError != 0)
    {
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0, (DWORD)dwError,0,buf,sizeof(buf),0);
    cout << buf << '\n';
    return TRUE;
    }
    return FALSE;

}

unsigned long GetValue (HKEY Key,std::string Name,unsigned long& Value)  {    
      unsigned long DataSize;
      DataSize = sizeof(long);                  
      ShowError(RegQueryValueEx (Key,Name.c_str(),0,NULL,(unsigned char*)&Value,
                               &DataSize));

      return Value;
    }

char* GetValue  (HKEY Key,std::string Name, char Value[1024])  {
      //memset (Value,0,sizeof(Value)/sizeof(char));
      Value[0] = 0;
      unsigned long DataSize = 1024;
                  
      ShowError(RegQueryValueEx (Key,Name.c_str(),0,NULL,(unsigned char*)Value,
                               &DataSize));

      return Value;
    }

int main()
{
    HKEY hKey = 0;
    char strValue[255] = {0};
    unsigned long dwValue = 0;
    if( ShowError(RegOpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Active Setup",&hKey)) )
    {
        return 1;
    }
    GetValue(hKey,"JITSetupPage",strValue);
    GetValue(hKey,"DisableRepair",dwValue);

    RegCloseKey(hKey);
    cout << strValue << '\n';
    cout << dwValue << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The first thing you need to do is check your computer's file system and see if the file name you enter is in the same directory as where your program is running. If it is somewhere else then you need to specify the full path to the file, such as c:\Prograzm Files\somethere. If the path and/or filename contains spaces, as I posted, then you can use the >> operator of cin, but you will have to use getline().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Post all the code so that we can test it. It must be referring to some other error because I know that RegQueryValueEx() exists.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why do people post *.zip files that can't be opened by WinZip??? What did you use to create that file?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

c++ standards state that you can not do that. The variable does NOT remain on the stack when the function returns because the state of the stack changes. That's the same as saying you can use a pointer after deleting it because the memory is still there. Well, it is, and it isn't.

>>What should GetLastError tell me
The error number (click here for details)

>>Anyway i'll try as i wanted to try earlier but this doesn't look like a common problem.And thanks
Ok, your funeral, not ours.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

At the time I wrote that I didn't know which one it was.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

nezachem is correct -- you have to allocate memory for the value using new. If that didn't work, then post your new code.

You must set DataSize = number of bytes in Value before calling RegQueryValueEx().

assert() only works when you compile the program for debug. It does nothing at all when the program is compiled without debug. So if the release mode program has an error you would never know about it except that the program might crash and burn. It would be better to call GetLastError() then FormatMessage() and finally print the message returned by FormatMessage(). You will get consistent results in both debug and release mode builds.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How did this topic turn from MFC to Windows Forms? Which one is it anyway?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm sure there have been many sociological studies on that subject. There are probably many reasons for it, including work environment, long work hours, deterioating personal family life, watching people die under the physician's knife.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In your button control OnClick() handler just call OnOk()

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

When your grandchildren are in college or get married.

jingda commented: Hey ! that is what i said before +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How?? Simple -- write the implementation code

class MyClass
{
public:
   MyClass()
   {
        cout << "Hello\n";
   {

Or if you don't want to or can't do it inline as above then put the code in a *.cpp file

class MyClass
{
public:
   MyClass();
   // blabla
};

// MyClass.cpp
#include "MyClas.h"

MyClass::MyClass()
{
   cout << "Hello\n";
}

You can also have empty constructors

class MyClass
{
public:
   MyClass() {}; // <<< empty constructor
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>typedef int Addr_t;

Why are you assuming addresses are integers? They aren't. Redefine that as typedef char* Addr_t; or typedef Tree* Addr_t , or whatever data type it is. If you need a generic pointer than typedef void* Addr_t; should do it, then you can typecast it to the appropriate type.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe you are calling CloseWindow() from the wrong window???

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is this an MFC program, or what? In Windows Forms CloseWindow() only minimizes the window. You want DestroyWindow().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The errors mean that you failed to write the implementation code for those functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

c++/CLR String class is not the same as c++ string class declared in <string> header file. Look up system::String class and review its methods

You can not use <string> in CLR/C++ programs, so you might as well delete that header file.

Example:

using namespace System;

int main(array<System::String ^> ^args)
{
    String^ s = gcnew String("Hello ");
    s = String::Concat(s," World");
    Console::Write(s);
    Console::Read();
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Microsoft does not directly support a grid control that is editable. To solve that problem I have used this grid control very successfully. For your project you will have to use either ODBC or ADO (depending on the databas you want to use) to do the queries and get the result sets, then populate the grid control with that data.

Suggest you upgrade your compiler to VC++ 2010 to get the benefit of compliance with current c++ standards and the .NET os. I don't know without some research if .NET has an editable grid control. Nor do I know what kind of database access it supports.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I'm not doing this inside any operating system

Oh! :-O Then how are you running that program?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The link error tells you that you have a symbol defined in two or more source files. You will just have to read all your source files to find the offending symbol. One way that can happen is to declare global variables in header files. To do that correctly you need to declare it with the extern keyword, such as extern int stuff; and then declare it once more in only one of the *.c or *.cpp files without extern.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You will probably have to do things a lot differently when porting from C to CLR/C++. Microsoft has made a lot of things much easier to do. Here is a tutorial for C#, which is a very close relative of CLR/C++.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

For this to work, you'll have to inspect each character from the stream using the isdigit() function.

Also you will have to get the input as a string and not as numeric data. If the valid checks pass (e.g. no non-digits entered) then you can easily convert the string to long.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The difference depends on the compiler you are using. Some compilers treat them the same, while others don't. With vc++ the <> tells the compiler to only look in its standard include directories (there are options to add to the list of directories), while the "" tells the compiler to first look in the program's source directory, it the header file is not there then the compiler will look in its standard directories just as if you had used <>.

I think google made a recent change to its search algorithms because some things seem to be more difficult to find than previously.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The short answer it No -- not with scanf(). scanf() will stop processing keyboard input when the first non-digit is reached or when no more charcters in the keyboard buffer. That function does no error checking.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A rottweiler dog so that I can teach pesty neighbors a few lessons. Superpowers: jaws of steel.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 1 thru 7: remove the semicolons at the end of those lines

The compiler vc++ 2010 express produces a lot of warnings about double to int and vice versa conversions. You should treat all those warnings as actual errors because they can often cause problems.

After making appropriate typecases and correcting line 130 (the while statement) I set bit to 32 and did not get program crash.

What values do we use for the three questions? I just put in some arbritrary numbers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

About 70% of Americans who go to college do it just to make more money. The rest of them are avoiding reality for about four more years.

In my youth people stayed in college to avoid the military draft (Viet Nam war was going on at the time). A HS grad friend of mine earned his Ph.D. in bio chemestry for that reason.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

looks like it is calling a function to see if two strings are equal or not.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

remove the -ansi flag and you won't get those warnings. The only reason I know of to use -ansi it to compile old lagecy code, written last century.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

All win32 api functions are C functions. Here are no c++ win32 api functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

He was banned not for what he said to and about me, but for spamming all the forms on PFO with a post nearly identical to this one. And I closed his threads to avoid pissing contests and/or flame wars, which is where those threads were headed. Up until he spammed all the forums his posts were entirely within the limits of the Rules, therefore no infractions or warnings.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Won't help. If you are converting from big to little endien (or vice versa) you will just simply have to rewrite the order of the bytes. typecasting will not affect that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ShellExecute() or CreateProcess(). Which to use depends on how much control you want over how the new process is created. Once the program is compiled it doesn't matter what language it was originally written in. The original language is lost in *.exe programs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Read through this tutorial -- it will teach you all the basics.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>long some_long = (long)&foo[6];

I think that's called undefined behavior, typecasting an address into a long integer. The two may or may not be the same size, depending on the compiler you are using.

The way I would do it is like this: long some_long = *(long *)&foo[6];

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm 16, the years are going to fast, i'm scared of getting old :/

Enjoy your life while you are young -- do everything and see everything you can. If you enjoy yourself then you won't even realize you are getting old(er). At your age if you are physically able you should be enjoying lots of sports, and chasing girls.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Read this thread for some hints. I have never participated in that kind of programming, so I won't be much help to you with that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just delete all the code previous to the line starting with POSITION. Its all useless code anyway.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The C iso standards won't show you how to write code as posted in the original post to this thread.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

surprisengly it even compiles without errors on vc++ 2010 Express

1>------ Rebuild All started: Project: test3, Configuration: Debug Win32 ------
1> stdafx.cpp
1> test3.c
1>c:\dvlp\test3\test3\test3.c(2): warning C4131: 'main' : uses old-style declarator
1>c:\dvlp\test3\test3\test3.c(2): warning C4431: missing type specifier - int assumed. Note: C no longer supports default-int
1>c:\dvlp\test3\test3\test3.c(3): warning C4013: 'scanf' undefined; assuming extern returning int
1>c:\dvlp\test3\test3\test3.c(7): warning C4013: 'printf' undefined; assuming extern returning int
1> test3.vcxproj -> c:\dvlp\test3\Debug\test3.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe you need to explain the problem a little more. The way I do it is to look at the monitor.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>When i deleted a struct,but then later on searched for another struct to delete,my search would stop at the "gap" created by the previous deletion

Yup, you have to teach your program to ignore deleted structs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>So,question is,how do i set a struct to null?
In an array, you can't. One way to do it is to add a deleted flag to the structure and set it to true if the struct is to be considered deleted. Another option is to set the first byte of the key field string to 0 to identify it as a deleted struct. A third option is to move all the remaining structs up one slot in the array, overwriting the struct you want to delete. That will leave an empty struct at the end of the array.

>>So,to put it simple,how do i set myArray[index] to null?
You can't, unless myArray is an array of pointers, such as MyStruct* myArray[MAX_ROWS]; In that case you call malloc() to allocate each of the rows in the array, and free() to delete one.

IMO a better solution would be to use a linked list, not an array. That will let you actually delete the node in the list and will leave no unused nodes.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its horribly recursive -- and illegal by today's C standards. But the code is using long-obsolete original K&R syntax.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Visual Studio 98??? That is almost as ancient as I am. Upgrade your version of VB to a more recent one. Start out with the free VB 2010 Express to see if that resolves your problem or not.

WaltP commented: I didn't know you were a teenager! Are you old enough to be here? :o) +16
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

User does not edit environment variables, your setup program should do that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>CPtrList& templateList =AfxGetApp()->GetFirstDocTemplatePosition();


That makes no sense at all. You need to do some serious reading if you intend to use MFC. Look up the functions you are trying to use and read what they return. In this case the function return POSITION object, not CPtrList object. You can't just toss random code at a program and expect it to work.

Yes, MFC is difficult to learn -- I'v read the average learning curve is about one year to learn it well.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yep, shred the constitution

No one but you mentioned shredding the constitution. I mean restoring it. Only shreding the congressional bills, which are not part of the constitution.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Congratulations Narue, I know you will be an excellent Admin. Narue is one of the brightest people I know here.