Home > Back-end >  How to thread synchronization in the DLL DLL injection
How to thread synchronization in the DLL DLL injection

Time:09-24

First said the younger brother now encountered difficulties in the work of the younger brother is a smaller counties in the city hospital a cashier cashier daily work in general is a patient comes in after I brush the patient card and said the patient should pay how many money because of hospital patients and the number of patients with oral communication up to 500 times a day at a time to talk about 10 seconds or longer and often occur at the same time in the exchange of language conflict (instead of I am not responsible for the county people quality is too low in my charge at the same time there are a lot of people didn't look also in consulting all kinds of problems I don't answer to me because I was afraid of brief paragraph and they have no sense of queuing hospital didn't take a variety of coercive measures such as set up barriers in line,,,,,)
Because I whim I self-study before computer technology to the whole charge for auxiliary out general function is on the charging interface by pressing "+" at the time of charging time deal successfully with my assistant to prompt the patient should pay RMB XXXXXX (implementation) play sound files, so here I was thinking about specific keyboard hook code I will not write

On the function of about the same but still some small bugs don't know how to deal with general situation described as follows:
While I press the + sign to start a thread broadcast voice said if I accidentally press the consecutive two + will play "the should pay XXXX" voice will appear in my EXE overlap can realize thread synchronization but is in the keyboard hook callback function has been don't know how to synchronize my baidu consecutive days without any result so I came here to look at Daniel great god can give the answer or way of thinking and a little because I haven't touched the programming for eight years when the cashier has learned knowledge waste a lot of so Daniel great spirit in answer, they don't say but as the saying goes, scribble gang brought what Buddha the most detailed solution given to the west as much as possible,

I was so tired I haven't been sleeping for more than 20 hours thank you!!!!!!

CodePudding user response:

Threads play media, lane is bad to can cause crashes, thread stagnation, false close such as fault, if you want to force a thread, to use the API function,
Suggestion:
http://blog.csdn.net/jankercsdn/article/details/8874469

Another: in view of the fact that you play, there is only one WAV, there is no parallel play, suggest that you did not use a thread to try and direct control of a media player MediaPlayer control, (or) directly using playSound function when duplicate gesture, first close the media, to play, it is more convenient,
Also can use third-party control, such as multimedia function library Bass. DLL, please refer to http://www.cnblogs.com/del/category/150851.html

CodePudding user response:

Control of your own, 5 seconds not repeat play ah

CodePudding user response:

Two schemes, the optional
1. If the old thread didn't end, a new playing thread won't play
2. If the old thread not over, stop, and then play the new

CodePudding user response:

Do a mutex oneself use Semaphore, prevent broadcast reentrant,

CodePudding user response:

Try to use critical region
ACriticalSection. Enter;
Try
PlaySound ();//here with synchronous broadcasting SND_SYNC
The finally
ACriticalSection. Leave;
end;

CodePudding user response:

Don't put the thread object defined as a local variable, defined as global, every time play, there does not exist, to judge the global thread variables can be controlled

CodePudding user response:

The eldest brother say so many I still don't understand

I said the general framework under the

The function keyd (... ) : a DWORD; Stdcall;//keyboard hook callback function
The begin
If (wp=vk_ADD) and (SHL 31 (1) and lp=0)
Then
Beginthread (nil, 0, @ play, nil, 0, Threadhandle);//play music music is composed of 20 WAV files
end;

CodePudding user response:

Ah, I give who can help me to complete the project file?

CodePudding user response:

Not said the don't use a thread to PLAY with you, saying I also seen WAVE function, can PLAY this movement is a surrender to all of the need to PLAY the cache, it is not necessary to use threads

CodePudding user response:

To, do not use thread, using PlaySound, specify SND_SYNC marks won't overlap played,
  • Related