-
[C++]GetPrivateProfileString(error..)
Hey, wollte mal fragen, wie ich den Fehler in diesem QC behebe
Code:
#include "windows.h"
char EinPfad[500];
char Nochwas[500];
char Test[500];
DWORD destSize;
destSize=500;
GetPrivateProfileString("common","C:\\Users\\","NULL",EinPfad,destSize,"test.ini");
//GetPrivateProfileString("common","Nochwas","NULL",Nochwas,destSize,"test.ini");
//GetPrivateProfileString("bla","test","NULL",Test,destSize,"test.ini");
"EinPfad" steht für einen beliebigen Pfad .. c:\\ ..
Code:
error C2664: 'GetPrivateProfileString': Konvertierung des Parameters 1 von 'const char [7]' in 'LPCTSTR' nicht möglich
-
AW: [C++]GetPrivateProfileString(error..)
Hab dein Source mal bissel Fixed, jetzt funktioniert es.
Glaube allerdings du hast den aufbau einer Ini-Datei nicht ganz verstanden.. wäre das möglich?
Wayne hier der Source:
Code:
#include <iostream>
#include <windows.h>
using namespace std;
char EinPfad[500];
char Nochwas[500];
char Test[500];
DWORD destSize=500;
int main(){
GetPrivateProfileString("common","Part2","NULL",EinPfad,500,"./test.ini");
cout<<EinPfad<<endl;
cin.get();
}
Und hier die test.ini
Code:
[common]
Part2=Dein_Pfad
-
AW: [C++]GetPrivateProfileString(error..)
ok+ danke, ich geh mal werkeln ;)
EDIT:
hab deine edit gelesen, muss es nur in eine visual c++ anwendung einbauen
also:
Code:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
char EinPfad[500];
char Nochwas[500];
char Test[500];
DWORD destSize=500;
GetPrivateProfileString("common","Part2","NULL",EinPfad,500,"./test.ini");
}
aber dann tritt wieder der convert-fehler auf:
Code:
error C2664: 'GetPrivateProfileString': Konvertierung des Parameters 1 von 'const char [7]' in 'LPCTSTR' nicht möglich
1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat.
-
AW: [C++]GetPrivateProfileString(error..)
Poste mal deinen gesammten Source auf pastebin.com oder so, kann mit deinem bisherigen Source nicht viel anfangen, der Fehler scheint wo anders als in dem Code den du gepostet hast zu liegen :confused:
-
AW: [C++]GetPrivateProfileString(error..)
-
AW: [C++]GetPrivateProfileString(error..)
Ich Programmier sonst in Devc++ und nicht mit Visual C++ deswegen hab ich nicht sonderlich viel Ahnung davon, kann dir aber erklären was den Fehler verursacht.
GetPrivateProfileString wurde von Visual C++ dekladiert, die richtigen Api funktionen heißen eigendlich GetPrivateProfileStringW oder GetTPrivateProfileStringA ,jeweils für Unicode und jemals ohne Unicode. Jetzt kannst du Theoretisch vor deine Strings (z.b "Part2" jeweils ein L setzen,also z.b L"Part2") um das als Unicode zu kennzeichnen . So ließ es sich bei mir dann Compilieren, das problem dabei ist jedoch das es nen Lesefehler gibt ("Geschützter Systemspeicher" bei ner ini datei, ja ne is klar).. Schau einfach mal, bekommst du sicher besser hin als ich.
-
AW: [C++]GetPrivateProfileString(error..)
Wahrscheinlich hast du Unicode als Kodierung eingestellt. Entweder du verwendest auch Unicode oder du stellst es in den Projekteinstellungen von "Unicode" auf "Multibyte".
-
AW: [C++]GetPrivateProfileString(error..)
wie macht man das ? :* habs noch nicht so mit änderungen am compiler <..< hab bisher immer die standarteinstellungen benutzt ..
-
AW: [C++]GetPrivateProfileString(error..)
Weiß ich jetzt nicht genau. Bei Projekt -> Projekteintellungen oder so.
Dann öffnet sich ein Fenster und ich glaube gleich im Standard-Tab kann man das ändern.
-
AW: [C++]GetPrivateProfileString(error..)
Oben auf Project->Properities->Configuration Properities->Characterset
-
AW: [C++]GetPrivateProfileString(error..)
-
AW: [C++]GetPrivateProfileString(error..)
Du sollst auch auf "Konfigurationseigenschaften" und nich auf Konfiguration! *kopfschüttel*
-
AW: [C++]GetPrivateProfileString(error..)
http://www.a-m-i.de/tips/strings/strings.php
probier deinen Stringparametern mal ein L voranzustellen.
Also
-
AW: [C++]GetPrivateProfileString(error..)
Zitat:
Zitat von
k0rxxx
Hab ich ihm schon empfohlen :D
Sollte das alles nichts helfen kannst du ja aber noch versuchen die Einstellungen vorzunehmen, und dann jeweils ein LPCTSTR davor zu setzen wie du es z.b bei einem DWORD machen würdest. So z.b -> (DWORD)variable
damit das ganze sich Compilieren lässt. Mit Devc++ hättest du das ganz einfach machen können ohne die ganzen Fehler , nur kannst du da eben nicht die Fensterchen zusammenklicken sondern musst es selbst coden :lol
Grüße
-
AW: [C++]GetPrivateProfileString(error..)
Zitat:
Zitat von
Surflam
Du sollst auch auf "Konfigurationseigenschaften" und nich auf Konfiguration! *kopfschüttel*
"Konfigurationseigenschaften" sieht genau gleich aus, wie im pic die Konfiguration
edit: wenn du das im pic meinst ..
-
AW: [C++]GetPrivateProfileString(error..)
Entweder du machst etwas falsch oder du hast ne falsche Version.. Sicher das du die 2010er Visual C++ hast?Bei der 2008er weiß ich nicht obs die Einstellung dort gibt.
http://img269.imageshack.us/img269/8563/visualc.png
-
AW: [C++]GetPrivateProfileString(error..)
ich hab Microsoft Visual C++ 2010 Express auf Deutsch und da find ich sowas, wie in deinem Pic nicht
PS: lol bin seit 3 Tagen nicht auf die Page gekommen, idk warums net ging
-
AW: [C++]GetPrivateProfileString(error..)
Das ging jedem so, Ddos und so..
-
AW: [C++]GetPrivateProfileString(error..)
Zitat:
Zitat von
GAFO
ich hab Microsoft Visual C++ 2010 Express auf Deutsch und da find ich sowas, wie in deinem Pic nicht
Wirklich nicht? Rechtsklick auf das Projekt -> Eigenschaften.
http://saved.im/mtg3mtewdzbp/unbenannt.png
-
AW: [C++]GetPrivateProfileString(error..)
Glaube er stellt sich einfach nur doof an :neutral:
Wenn du möchtest, kann ichs dir Morgen oder so mal per Teamviewer schauen ;)
-
AW: [C++]GetPrivateProfileString(error..)
Sowie ich das sehe macht GAFO nen Rechtsklick auf die Projektmappe und nicht auf das Projekt. ;)
Auf psysnake screen sieht mans gut, auf "tutzu" klicken, nicht auf "Projektmappe tutzu".
MfG Leange
-
AW: [C++]GetPrivateProfileString(error..)
Man kann auch oben in der Statusleite auf "Projekt(e)" klicken,und dann auf Projekteigenschaften - öffnet das selbe fensterchen.
-
AW: [C++]GetPrivateProfileString(error..)
hat geklappt !! einfach Visual c++ neu installiert LOL <..< :idee:eek::idee
jetzt ist nur noch der Punkt ungeklärt, wie man in
Code:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
char EinPfad[500];
char Nochwas[500];
char Test[500];
DWORD destSize=500;
GetPrivateProfileString("common","Part2","NULL",EinPfad,500,"C:\Users\Lightning\Desktop\/test.ini");
}
EinPfad mit dem Text einer z.B. TextBox gleichsetzt, denn
Code:
tb1->Text = EinPfad;
// bzw
tb1->Text(EinPfad);
geht nicht
-
AW: [C++]GetPrivateProfileString(error..)
sicher das du es richtig benannt hast?Ich hatte anfangs das Problem das ich nicht auf Groß/Kleinschreibung geachtet hatte und es dann deswegen nicht klappte.
-
AW: [C++]GetPrivateProfileString(error..)
Code:
rror C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)': Konvertierung des Parameters 1 von 'char [500]' in 'System::String ^' nicht möglich
1> Ursache: Konvertierung von 'char *' in 'System::String ^' nicht möglich
das müsste man iwie anders machen als, wie in dem bsp
-
AW: [C++]GetPrivateProfileString(error..)
steht ja schon da was zu machen ist
"Konvertierung von 'char *' in 'System::String ^' nicht möglich"
Sprich du musst ein String und kein char* benutzen damit es funktioniert, da ein String erwartet wird. Oder du wandelst es bevor du es Anzeigst dann in ein String um (ging glaube ich mit variable.c_str();) ;)
-
AW: [C++]GetPrivateProfileString(error..)
ja, selbst wenn ich da statt nem char array nen system-string benutze, also "String" kommt bei :
Code:
1>c:\users\lightning\documents\visual studio 2010\projects\na\ini-ausleser\ini-ausleser\Form1.h(96): error C3149: "System::String": Dieser Typ kann ohne "^" der obersten Ebene hier nicht verwendet werden.
1>c:\users\lightning\documents\visual studio 2010\projects\na\ini-ausleser\ini-ausleser\Form1.h(102): error C2664: 'GetPrivateProfileString': Konvertierung des Parameters 4 von 'System::String ^' in 'LPTSTR' nicht möglich