whiles_
29-08-2006, 15:10
mi sto avvicinando a c++ per fare un'applicazione che mi serve in particolar modo. Praticamente ho fatto un casino: la funzione API SHGetFolderPath(); ritorna nell'ultimo argomento una stringa unicode che riesco a gestire solo con wcout e wchar_t.
La funzione getUserId, presa come argomento una stringa, la "cripta" con un metodo tutto suo. La funzione GetGlobalDataFolder restituisce la cartella "Dati Applicazioni", mentre GetUserDataFolder unisce le due funzioni restituendo un percorso formato da [GetGlobalDataFolder]/percorso/[getUserId].
Ho provato a convertire tutti i char e i cout in char_t e wcout, ho provato a convertire la stringa di ritorno dall'api in un char ma non ci sono riuscito :cry: Cosa posso fare? non ci capisco più niente , non riesco proprio a farla funzionare :cry: :help:
#define NULL ((void*)0)
#define WIN32_LEAN_AND_MEAN
#include <windows>
#include <stdafx.h>
#include <iostream> // per std::cout e std::endl
#include <pdh.h>
#include <shlobj.h>
#include <string>
using namespace std;
long getUserId(const char *);
wchar_t* getUserDataFolder(const char *);
wchar_t* getGlobalDataFolder();
int main()
{
wcout << getUserDataFolder("email@hotmail.it") << endl;
cout << getUserId("email@hotmail.it") << endl;
wcout << getGlobalDataFolder() << endl;
system("pause");
return 0;
}
long getUserId(const char * user)
{
unsigned int x = 0;
for (int i = 0; i < strlen(user); i++) {
x = x * 101;
x = x + towlower(user[i]);
}
return x;
}
wchar_t* getUserDataFolder(const char* user) {
return getGlobalDataFolder() + L"Microsoft\\MSN Messenger\\" + wchar_t(getUserId(user)) + endl;
}
wchar_t* getGlobalDataFolder() {
TCHAR path[MAX_PATH];
SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path);
return path;
}
l'errore che mi da è "error C2110: '+' : cannot add two pointers", e non riesco ad unire quelle stringhe al return... anche riuscire a convertire un char in un wchar_t potrebbe essere un grande passo :(
grazie infinite
La funzione getUserId, presa come argomento una stringa, la "cripta" con un metodo tutto suo. La funzione GetGlobalDataFolder restituisce la cartella "Dati Applicazioni", mentre GetUserDataFolder unisce le due funzioni restituendo un percorso formato da [GetGlobalDataFolder]/percorso/[getUserId].
Ho provato a convertire tutti i char e i cout in char_t e wcout, ho provato a convertire la stringa di ritorno dall'api in un char ma non ci sono riuscito :cry: Cosa posso fare? non ci capisco più niente , non riesco proprio a farla funzionare :cry: :help:
#define NULL ((void*)0)
#define WIN32_LEAN_AND_MEAN
#include <windows>
#include <stdafx.h>
#include <iostream> // per std::cout e std::endl
#include <pdh.h>
#include <shlobj.h>
#include <string>
using namespace std;
long getUserId(const char *);
wchar_t* getUserDataFolder(const char *);
wchar_t* getGlobalDataFolder();
int main()
{
wcout << getUserDataFolder("email@hotmail.it") << endl;
cout << getUserId("email@hotmail.it") << endl;
wcout << getGlobalDataFolder() << endl;
system("pause");
return 0;
}
long getUserId(const char * user)
{
unsigned int x = 0;
for (int i = 0; i < strlen(user); i++) {
x = x * 101;
x = x + towlower(user[i]);
}
return x;
}
wchar_t* getUserDataFolder(const char* user) {
return getGlobalDataFolder() + L"Microsoft\\MSN Messenger\\" + wchar_t(getUserId(user)) + endl;
}
wchar_t* getGlobalDataFolder() {
TCHAR path[MAX_PATH];
SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path);
return path;
}
l'errore che mi da è "error C2110: '+' : cannot add two pointers", e non riesco ad unire quelle stringhe al return... anche riuscire a convertire un char in un wchar_t potrebbe essere un grande passo :(
grazie infinite