我在C中创建了一个Ts3插件,它应该读取2个值,并且我想使用c ++对其进行外部访问
plugin.c:
int isMuted_INPUT = -1, isMuted_OUTPUT = -1;
void ts3plugin_onUpdateClientEvent(uint64 serverconnectionhandlerID, anyID clientID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) {
if (ts3Functions.getClientSelfVariableAsInt(serverconnectionhandlerID, CLIENT_INPUT_MUTED, &isMuted_INPUT) == ERROR_ok) {
printf("[MuteStatusHelper] Mute STATUS INPUT: %i\n", isMuted_INPUT);
}
if (ts3Functions.getClientSelfVariableAsInt(serverconnectionhandlerID, CLIENT_OUTPUT_MUTED, &isMuted_OUTPUT) == ERROR_ok) {
printf("[MuteStatusHelper] Mute STATUS OUTPUT: %i\n", isMuted_OUTPUT);
}
}
int getMuteStatus_INPUT() {
return isMuted_INPUT;
}
int getMuteStatus_OUTPUT() {
return isMuted_OUTPUT;
}
plugin.h:
__declspec(dllexport) int __cdecl getMuteStatus_INPUT(void);
__declspec(dllexport) int __cdecl getMuteStatus_OUTPUT(void);
它应该返回0或1,但返回-1 出于测试目的将其更改为
int getMuteStatus_INPUT() {
return 345;
}
返回345
main.cpp
typedef HRESULT(CALLBACK* LPFNDLLFUNC1)();
int main()
{
HINSTANCE hGetProcIDDLL = LoadLibrary(L"C:\\Program Files (x86)\\TeamSpeak 3 Client\\plugins\\MuteStatusHelper.dll");
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE(hGetProcIDDLL), "getMuteStatus_INPUT");
typedef int(__cdecl * pICFUNC)();
pICFUNC MyFunction;
MyFunction = pICFUNC(lpfnGetProcessID);
int Result = MyFunction();
std::cout << "INPUT WERT: " << Result << std::endl;
//FreeLibrary(hGetProcIDDLL);
}