Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

WCHAR to std::string ?

Empfohlene Antworten

Veröffentlicht

Hallo Freunde!

Wie viele von euch bereits mitbekommen haben, habe ich erst letzens einen Code gesucht, um meinen Ordner auslesen zu lassen. Das funtkioniert wunderbar:

	HANDLE handle;

	WIN32_FIND_DATA finddata; 

	handle = FindFirstFile(TEXT("temp\\*"),&finddata);

	FindNextFile(handle,&finddata);

	while (FindNextFile(handle,&finddata))

	{

		wcout << finddata.cFileName << endl;

	}

	FindClose(handle);

Jedoch habe ich ein Problem: finddata.cFileName ist vom Datentyp her ein WCHAR, ich brauch aber ein std::string für viele Funtkionen ( eine von denen is Write / GetPrivateProfileString ). Ich hab mir schon gedacht, dass ich anstatt GetPrivateProfileStringA einfach W nehmen soll, jedoch muss ich dann meine Strings in WCHARs umwandeln, das macht die sache nicht sinvoller :(

Gibt es eine möglichkeit WCHAR in std::string umzuwandeln, oder kann man gleich die einzelnen Dateinamen direkt in std::string speichern?

Vielen dank für eure Hilfe

Liebe Grüße,

errox

Ich hab mir schon gedacht, dass ich anstatt GetPrivateProfileStringA einfach W nehmen soll,
Wieso auch nicht? Du benutzt ja auch FindFirstFileW, nicht FindFirstFileA. ;)

jedoch muss ich dann meine Strings in WCHARs umwandeln, das macht die sache nicht sinvoller :(
Doch, wenn du ständig mit Wide-Character-Funktionen arbeitest, ist das durchaus sinnvoll.

Gibt es eine möglichkeit WCHAR in std::string umzuwandeln

WideCharToMultiByte

Das ist aber immer verbunden mit einer neuen Zeichencodierung.

oder kann man gleich die einzelnen Dateinamen direkt in std::string speichern?
Nimm FindFirstFileA und WIN32_FIND_DATAA. Oder stell in deinem Projekt Unicode ganz ab, wenn du die Unicode-Funktionen sowieso nicht willst.
  • Autor

Oh mein gott, ich i****. Vielen Dank. Als Guter Programmierer wäre ich selbst drauf gekommen.

Was würde ich ohne dich machen? :D

nochmals danke!!!

Liebe Grüße,

errox

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.