//在用户数据目录下写一个utf-8的 UserProfile.xcu
using namespace std;
char buffer[ BUF_SIZE ];
memset( buffer, 0, BUF_SIZE );
SHGetSpecialFolderPathA( NULL, buffer, CSIDL_APPDATA, FALSE )
std::_tstring UserProfilepath = buffer;
UserProfilepath += TEXT( "\\NeoShineOffice\\5\\user\\registry\\data\\org\\openoffice" );
//MessageBox(NULL, UserProfilepath.c_str(), TEXT("ShowReleaseNotesAfter"), MB_OK);
//ANSI to UNICODE
size_t size = UserProfilepath.length();
wchar_t *buffer1 = new wchar_t[size+1];
MultiByteToWideChar( CP_ACP, 0, UserProfilepath.c_str(), size, buffer1, size * sizeof(wchar_t) );
buffer1[size] = 0;
SHCreateDirectory(0,buffer1);
delete buffer1;
std::_tstring UserProfileText =TEXT("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<oor:component-data xmlns:oor=\"http://openoffice.org/2001/registry\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" oor:name=\"UserProfile\" oor:package=\"org.openoffice\">\n <node oor:name=\"Data\">\n <prop oor:name=\"o\" oor:type=\"xs:string\">\n <value>");
std::_tstring COMPANYNAME = GetMsiProperty( handle, TEXT("COMPANYNAME") );
UserProfileText+=COMPANYNAME.c_str();//
UserProfileText+=TEXT("</value>\n </prop>\n <prop oor:name=\"givenname\" oor:type=\"xs:string\">\n <value>");
std::_tstring USERNAME = GetMsiProperty( handle, TEXT("USERNAME") );
UserProfileText+=USERNAME.c_str();//
UserProfileText+=TEXT("</value>\n </prop>\n <prop oor:name=\"initials\" oor:type=\"xs:string\">\n <value></value>\n </prop>\n </node>\n</oor:component-data>");
UserProfilepath+=TEXT("\\UserProfile.xcu");
//ANSI >>>> Unicode
int ulen=::MultiByteToWideChar(CP_ACP,NULL,UserProfileText.c_str(),UserProfileText.length(),NULL,0);
wchar_t * userString =new wchar_t[ulen+1];
::MultiByteToWideChar(CP_ACP,NULL,UserProfileText.c_str(),UserProfileText.length(),userString,ulen);
userString[ulen]='\0';
//MessageBox(0,userString,"Msg",MB_OK);
//Unicode >>>> UTF-8
FILE *fp;
fp=fopen(UserProfilepath.c_str(),"wb+");
//char line[3]; //UTF-8 file header
//line[0]=0xef;
//line[1]=0xbb;
//line[2]=0xbf;
//fwrite(line,sizeof(char),3,fp);//这个标志 非必须似乎 自动会创建
char lines[BUF_SIZE];
int len=WideCharToMultiByte(CP_UTF8,0,userString,ulen,lines,BUF_SIZE,NULL,NULL);
//::MessageBox(0,lines,"Msg",MB_OK);
fwrite(lines,sizeof(char),len,fp);
char buffer[ BUF_SIZE ];
memset( buffer, 0, BUF_SIZE );
SHGetSpecialFolderPathA( NULL, buffer, CSIDL_APPDATA, FALSE )
std::_tstring UserProfilepath = buffer;
UserProfilepath += TEXT( "\\NeoShineOffice\\5\\user\\registry\\data\\org\\openoffice" );
//MessageBox(NULL, UserProfilepath.c_str(), TEXT("ShowReleaseNotesAfter"), MB_OK);
//ANSI to UNICODE
size_t size = UserProfilepath.length();
wchar_t *buffer1 = new wchar_t[size+1];
MultiByteToWideChar( CP_ACP, 0, UserProfilepath.c_str(), size, buffer1, size * sizeof(wchar_t) );
buffer1[size] = 0;
SHCreateDirectory(0,buffer1);
delete buffer1;
std::_tstring UserProfileText =TEXT("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<oor:component-data xmlns:oor=\"http://openoffice.org/2001/registry\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" oor:name=\"UserProfile\" oor:package=\"org.openoffice\">\n <node oor:name=\"Data\">\n <prop oor:name=\"o\" oor:type=\"xs:string\">\n <value>");
std::_tstring COMPANYNAME = GetMsiProperty( handle, TEXT("COMPANYNAME") );
UserProfileText+=COMPANYNAME.c_str();//
UserProfileText+=TEXT("</value>\n </prop>\n <prop oor:name=\"givenname\" oor:type=\"xs:string\">\n <value>");
std::_tstring USERNAME = GetMsiProperty( handle, TEXT("USERNAME") );
UserProfileText+=USERNAME.c_str();//
UserProfileText+=TEXT("</value>\n </prop>\n <prop oor:name=\"initials\" oor:type=\"xs:string\">\n <value></value>\n </prop>\n </node>\n</oor:component-data>");
UserProfilepath+=TEXT("\\UserProfile.xcu");
//ANSI >>>> Unicode
int ulen=::MultiByteToWideChar(CP_ACP,NULL,UserProfileText.c_str(),UserProfileText.length(),NULL,0);
wchar_t * userString =new wchar_t[ulen+1];
::MultiByteToWideChar(CP_ACP,NULL,UserProfileText.c_str(),UserProfileText.length(),userString,ulen);
userString[ulen]='\0';
//MessageBox(0,userString,"Msg",MB_OK);
//Unicode >>>> UTF-8
FILE *fp;
fp=fopen(UserProfilepath.c_str(),"wb+");
//char line[3]; //UTF-8 file header
//line[0]=0xef;
//line[1]=0xbb;
//line[2]=0xbf;
//fwrite(line,sizeof(char),3,fp);//这个标志 非必须似乎 自动会创建
char lines[BUF_SIZE];
int len=WideCharToMultiByte(CP_UTF8,0,userString,ulen,lines,BUF_SIZE,NULL,NULL);
//::MessageBox(0,lines,"Msg",MB_OK);
fwrite(lines,sizeof(char),len,fp);