D
Hallo, folgendes Problem:
ich muss via C++ eine Accessdatenbank öffnen. Dies mache ich, indem ich den Pfad zur Accessdatenbank in eine ini-Datei schreibe, diesen Pfad dann auslese und ihn an ShellExecute übergebe. Funktioniert lokal auf mienem Rechner alles wunderbar, ohne Probleme. Liegt meine exe incl. ini und datenbank nun aber auf einem Server, so bekomme ich immer die Fehlermeldung: "The specified path was not found".
folgender Code:
#include <iostream>
#include <Windows.h>
#include <stdlib.h>
#include <string>
using namespace std;
void main(int argc, char* argv[])
{
Sleep(500);
char actualPath[256];
char pfad[100];
string pfadS = argv[0];
string pathOnly;
char pfadAusDatei[256];
char debug[2] = {'9','9'};
GetModuleFileName(NULL,actualPath,256);
pathOnly = pfadS.substr(0,(pfadS.length()-(pfadS.length()-pfadS.find_last_of('\\'))));
pfadS = pathOnly + "\\database.ini";
GetPrivateProfileString("database","pfad","Fehler!",pfadAusDatei,256,/*inidatei*/pfadS.c_str());
GetPrivateProfileString("database","debug","Fehler!",debug,256,pfadS.c_str());
if(debug[0] == '0')
{
}
else if (debug[0] == '1' )
{
cout << "Zu oeffnende Datei:" << pfadAusDatei << endl;;
}
else
{
}
cout << "Shellexecute:" << endl;
HINSTANCE test = ShellExecute(NULL,"open",pfadAusDatei,"/runtime",NULL,1);
int test2 = (int)test;
if(debug[0] == '1')
{
switch(test2)
{
case ERROR_FILE_NOT_FOUND:
cout << "The specified file was not found." << endl;
break;
case 0:
cout << "The operating system is out of memory or resources." << endl;
break;
case ERROR_PATH_NOT_FOUND:
cout << "The specified path was not found" << endl;
break;
case ERROR_BAD_FORMAT:
cout << "The .exe file is invalid (non-Win32 .exe or error in .exe image)." << endl;
break;
case SE_ERR_ACCESSDENIED:
cout << "The operating system denied access to the specified file." << endl;
break;
case SE_ERR_ASSOCINCOMPLETE:
cout << "The file name association is incomplete or invalid." << endl;
break;
case SE_ERR_DDEBUSY:
cout << "The DDE transaction could not be completed because other DDE transactions were being processed." << endl;
break;
case SE_ERR_DDEFAIL:
cout << "The DDE transaction failed." << endl;
break;
case SE_ERR_DDETIMEOUT:
cout << "The DDE transaction could not be completed because the request timed out." << endl;
break;
case SE_ERR_DLLNOTFOUND:
cout << "The specified DLL was not found." << endl;
break;
case SE_ERR_NOASSOC:
cout << "There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable." << endl;
break;
case SE_ERR_OOM:
cout << "There was not enough memory to complete the operation." << endl;
break;
case SE_ERR_SHARE:
cout << "A sharing violation occurred." << endl;
break;
default:
if(test2>32)
{
cout << "Datei erfolgreich geöffnet!" << endl;
}
else
{
cout << "Es ist ein unerwarteter Fehler aufgetreten!" << endl;
}
}
}
if (debug[0] == '1' )
{
cin.get();
}
}
Der Pfad steht wie Folgt in der ini-Datei: "\\\Zentrale\_Q12\\P-Seminar\"
kann mir da vllt irgendeiner weiterhelfen ? Bräuchte am besten bis morgen eine Lösung. Danke schon mal an alle im voraus.
lg, Duck93