-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
69 lines (61 loc) · 1.56 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <AknGlobalNote.h>
LOCAL_C TBool running()
{
TBool ret = EFalse;
TFullName res;
TFindProcess find;
while(find.Next(res) == KErrNone)
{
RProcess ph;
User::LeaveIfError(ph.Open(res));
if(ph.SecureId() == 537047821)
if (ph.ExitType() == EExitPending)
{
ret = ETrue;
break;
}
ph.Close();
}
return ret;
}
LOCAL_C void kill(const TDesC &process)
{
TFullName res;
TFindProcess find(process);
while(find.Next(res) == KErrNone)
{
RProcess ph;
User::LeaveIfError(ph.Open(find));
ph.Kill(KErrNone);
ph.Close();
}
}
LOCAL_C void ExeMainL()
{
if (!running())
{
CAknGlobalNote* note = CAknGlobalNote::NewLC();
TRequestStatus iStatus;
note->ShowNoteL(iStatus, EAknGlobalErrorNote, _L("Error.\nThis app is designed to close WhatsApp. WhatsApp isn't installed or running on your device."));
User::WaitForRequest(iStatus);
CleanupStack::PopAndDestroy(note);
}
else
{
CAknGlobalNote* note = CAknGlobalNote::NewLC();
TRequestStatus iStatus;
note->ShowNoteL(iStatus, EAknGlobalConfirmationNote, _L("Success.\nClosed WhatsApp."));
kill(_L("*[2002B306]*"));
kill(_L("*[2002B310]*"));
kill(_L("*[2002B30D]*"));
User::WaitForRequest(iStatus);
CleanupStack::PopAndDestroy(note);
}
}
TInt E32Main()
{
CTrapCleanup* cl=CTrapCleanup::New();
TRAPD(error, ExeMainL());
delete cl;
return 0;
}