E
ahhh...
hab ne ziemlich lange zeit gebraucht, um auf ne doch recht einfache lösung zu kommen.
Mit LoadLibraryEx(L"C:\\Windows\\System32\\AudioSrv.Dll",NULL,LOAD_LIBRARY_AS_DATAFILE) funktionierts wie gewünscht.
Hab mir dann auch gleich ne Funktion gebastelt, die den gesamten "Referenz"-String in den Menschenlesbaren umwandelt
#define RSR_RET_NOERR 0
#define RSR_RET_INTFUNCERR -1
#define RSR_RET_STRERR -2
#define RSR_RET_PTRERR -3
int ReplaceStringRef(LPCWSTR pIn, LPWSTR *pOut)
{
LPWSTR tmpOut;
int outStrLen=0;
if(pIn[0]=='@') //handelt es sich um einen "Referenz-String"?
{
int commapos;
for(commapos=wcslen(pIn);commapos>0&&pIn[commapos]!=',';commapos--);
if(commapos==0)
{
return RSR_RET_STRERR;
}
LPWSTR lpPathTmp=new wchar_t[commapos+1];
LPWSTR lpRefNum=new wchar_t[wcslen(pIn)-commapos-1];
wcsncpy_s(lpPathTmp,commapos+1,pIn+1,commapos-1);
wcsncpy_s(lpRefNum,wcslen(pIn)-commapos-1,pIn+commapos+2,wcslen(pIn)-commapos-1);
int RefNum;
swscanf_s(lpRefNum,L"%i",&RefNum);
delete [] lpRefNum;
DWORD expNeNum=ExpandEnvironmentStrings(lpPathTmp,NULL,0);
if(expNeNum==0)
{
delete [] lpPathTmp;
return RSR_RET_INTFUNCERR;
}
LPWSTR lpPath=new wchar_t[expNeNum];
if(ExpandEnvironmentStrings(lpPathTmp,lpPath,expNeNum)==0)
{
delete [] lpPath;
return RSR_RET_INTFUNCERR;
}
delete [] lpPathTmp;
HMODULE lib=LoadLibraryEx(lpPath,NULL,LOAD_LIBRARY_AS_DATAFILE);
if(lib==0)
{
delete [] lpPath;
return RSR_RET_INTFUNCERR;
}
delete [] lpPath;
for(int i=1;outStrLen==0||outStrLen==(i-1)*32-1;i++)
{
tmpOut=new wchar_t[i*32];
outStrLen=LoadString(lib,RefNum,tmpOut,i*32);
if(outStrLen==0)
{
delete [] tmpOut;
FreeLibrary(lib);
return RSR_RET_INTFUNCERR;
}
else if (outStrLen==i*4-1)
{
delete [] tmpOut;
}
}
outStrLen++;
FreeLibrary(lib);
}
else
{
outStrLen=wcslen(pIn)+1;
tmpOut=new wchar_t[outStrLen];
for(int i=0;i<outStrLen;i++)tmpOut[i]=pIn[i];
}
if(pOut==NULL)
{
delete [] tmpOut;
return RSR_RET_PTRERR;
}
*pOut=new wchar_t[outStrLen]; //String mit der richtigen länge ohne ungenutzte zeichen nach dem 0-Terminator
wcsncpy_s(*pOut,outStrLen,tmpOut,outStrLen-1);
delete [] tmpOut;
return RSR_RET_NOERR;
}
man muss aber den pointer der ausgabe manuell mit delete [] freigeben.
funktioniert wie gewollt.
danke trotzdem für eure mühen
Ele