You are incorrectly assuming that the application is called from the folder it is located.
You will have to get the path of the current application and then combine it with the name of the config file. For example:
char buffer[MAX_PATH];
GetModuleFileNameA( NULL, buffer, MAX_PATH );
PathRemoveFileSpecA(buffer);
char cfg_path[MAX_PATH];
PathCombineA(cfg_path, MAX_PATH, buffer, "config.cfg");
// cfg_path now contains the full path to the config file
An alternative solution is to pass the path to the config file as the first argument to the application. This will mean changing the command in the registry to something like "C:\Program Files\MyProtocol\MyProtocol.exe" "C:\Program Files\MyProtocol\config.cfg" "%1"
. Then the code can be changed to the following:
int main(int argc, char* argv[]) {
if( argc<2 ) return -1;
std::ifstream file(argv[1]);
// ...
}