Calling the Windows WinMM DLL
843829Oct 8 2002 — edited Oct 9 2002Hi,
I am trying to call the method WaveInGetDevCaps in the WinMM.dll
without success as shown below:
typedef UINT (*INPUTDEVCAPS)(UINT, LPWAVEINCAPS, UINT);
/*
* Class: PCDevices
* Method: getMicDeviceNameOnPC
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_PCDevices_getMicDeviceNameOnPC
(JNIEnv * env, jobject obj, jint id) {
WAVEINCAPS caps;
INPUTDEVCAPS devCaps = (INPUTDEVCAPS) GetProcAddress(ref, "waveInGetDevCapsW");
if (devCaps != NULL) {
int status = (devCaps)(0, &caps, sizeof(WAVEINCAPS));
if (status == MMSYSERR_NOERROR) {
return env->NewStringUTF(caps.szPname);
} else {
return env->NewStringUTF("Error");
}
} else {
FreeLibrary(ref);
}
}
Initially the GetProcAddress failed when I used the generic method name WaveInGetDevCaps
without the "W". Which is strange because other methods in this DLL work without the Suffix
e.g. waveInGetNumDevs().
When I use the suffix I then get the following error:
"The value of ESP was not properly saved across a function call"
I would appreciate if someone could help me with this problem as I am not sure how now
to proceed.
Thanks in advance
Steve