Archimedes
April 26th, 2005, 03:41 PM
This question takes many forms. The problem I am having is that I am creating a windows service. In it I want to pop up a dialog box, so I need to use the MessageBox::Show method from System::Windows::Forms. This works fine. However, if I want to use a function like GetModuleFileName, then I have to include windows.h. This immediately breaks the compiler, which tells me either a) MessageBoxW is not a class or namespace, or b) if I use full naming such as System::Windows::Forms::MessageBox::Show() that MessageBoxW is not a member of System::Windows::Forms. What is the conflict? Am I misunderstanding the use of namespaces, etc?
#include "stdafx.h"
#include "file.h"
#include <fstream>
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
using namespace System::Windows::Forms;
void OpenFiles()
{
ofstream Output;
ifstream Input;
char szAppPath[MAX_PATH] = "";
string strAppDirectory;
::GetModuleFileNameA(0, szAppPath, sizeof(szAppPath) - 1);
// Extract directory
strAppDirectory = szAppPath;
strAppDirectory = strAppDirectory.substr(0, strAppDirectory.rfind("\\"));
...
MessageBox::Show("Output open failed!!", "Start", MessageBoxButtons::OK, MessageBoxIcon::Asterisk,
MessageBoxDefaultButton::Button1, MessageBoxOptions::ServiceNotification);
...
}
#include "stdafx.h"
#include "file.h"
#include <fstream>
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
using namespace System::Windows::Forms;
void OpenFiles()
{
ofstream Output;
ifstream Input;
char szAppPath[MAX_PATH] = "";
string strAppDirectory;
::GetModuleFileNameA(0, szAppPath, sizeof(szAppPath) - 1);
// Extract directory
strAppDirectory = szAppPath;
strAppDirectory = strAppDirectory.substr(0, strAppDirectory.rfind("\\"));
...
MessageBox::Show("Output open failed!!", "Start", MessageBoxButtons::OK, MessageBoxIcon::Asterisk,
MessageBoxDefaultButton::Button1, MessageBoxOptions::ServiceNotification);
...
}