| View previous topic :: View next topic |
| Author |
Message |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sat Jan 24, 2009 8:56 am Post subject: |
|
|
that way seems fine. but instead of:
| Code: | curname = lppe.szExeFile;
if(strcmp(procname, curname) == 0){
return 0;
} |
you can just do:
| Code: | if(!strcmp(procname, lppe.szExeFile))
{
return 0;
} |
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Sat Jan 24, 2009 11:16 am Post subject: |
|
|
Ugh those std:: namespace annoys me, why not | Code: | | using namespace std; | then you won't have to type std:: for every std function?
|
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sat Jan 24, 2009 1:25 pm Post subject: |
|
|
| Slugsnack wrote: | that way seems fine. but instead of:
| Code: | curname = lppe.szExeFile;
if(strcmp(procname, curname) == 0){
return 0;
} |
you can just do:
| Code: | if(!strcmp(procname, lppe.szExeFile))
{
return 0;
} |
|
It doesent seem to work
| _void_ wrote: | Ugh those std:: namespace annoys me, why not | Code: | | using namespace std; | then you won't have to type std:: for every std function? |
I dunno, everyone says to not add them, so i do not O.o
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Sat Jan 24, 2009 1:52 pm Post subject: |
|
|
Try...
| Code: |
if(strcmp(procname, &lppe.szExeFile) == 0)
|
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Sat Jan 24, 2009 2:35 pm Post subject: |
|
|
Also, at CreateToolhelp32Snapshot, you can also use TH32CS_SNAPPROCESS, instead of TH32CS_SNAPALL, because the latter one will also get other information which you don't need in this case.
| _void_ wrote: | Try...
| Code: |
if(strcmp(procname, &lppe.szExeFile) == 0)
|
|
Don't think that would work. szExeFile is already a pointer to the string.
if( !strcmp(procname, lppe.szExeFile) ) should work
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Sat Jan 24, 2009 2:50 pm Post subject: |
|
|
| tombana wrote: | Also, at CreateToolhelp32Snapshot, you can also use TH32CS_SNAPPROCESS, instead of TH32CS_SNAPALL, because the latter one will also get other information which you don't need in this case.
| _void_ wrote: | Try...
| Code: |
if(strcmp(procname, &lppe.szExeFile) == 0)
|
|
Don't think that would work. szExeFile is already a pointer to the string.
if( !strcmp(procname, lppe.szExeFile) ) should work |
I like being careful since szExeFile is TCHAR and procname is char.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sat Jan 24, 2009 3:03 pm Post subject: |
|
|
| look at my source, i do the same thing. btw try changing your character set to multi byte instead of unicode.
|
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sat Jan 24, 2009 3:26 pm Post subject: |
|
|
| _void_ wrote: | | tombana wrote: | Also, at CreateToolhelp32Snapshot, you can also use TH32CS_SNAPPROCESS, instead of TH32CS_SNAPALL, because the latter one will also get other information which you don't need in this case.
| _void_ wrote: | Try...
| Code: |
if(strcmp(procname, &lppe.szExeFile) == 0)
|
|
Don't think that would work. szExeFile is already a pointer to the string.
if( !strcmp(procname, lppe.szExeFile) ) should work |
I like being careful since szExeFile is TCHAR and procname is char. |
main.cpp(25) : error C2664: 'strcmp' : cannot convert parameter 2 from 'CHAR (*)[260]' to 'const char *'
Nomatter what, the only thing that works, is the one i posted as a start...
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sat Jan 24, 2009 4:08 pm Post subject: |
|
|
| remove the &, it's already a pointer to the string.
|
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sat Jan 24, 2009 4:30 pm Post subject: |
|
|
| slovach wrote: | | remove the &, it's already a pointer to the string. |
I know... it was just to tell him that it wouldn't work O.o
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sat Jan 24, 2009 4:39 pm Post subject: |
|
|
| i already told you what to do. unicode >> multibyte
|
|
| Back to top |
|
 |
Skyance Cheater
Reputation: 0
Joined: 07 Sep 2007 Posts: 46 Location: Israel
|
Posted: Sun Jan 25, 2009 2:04 am Post subject: |
|
|
| Slugsnack wrote: | that way seems fine. but instead of:
| Code: | curname = lppe.szExeFile;
if(strcmp(procname, curname) == 0){
return 0;
} |
you can just do:
| Code: | if(!strcmp(procname, lppe.szExeFile))
{
return 0;
} |
|
True, however I find it very annoying...
I use !(condition) to check wether a condition is false, e.g. a function has failed.
strcmp returns 0 when the two strings are identical, not when it fails, so I prefer == 0 or at least == ERROR_SUCCESS. ("#define ERROR_SUCCESS 0")
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Jan 25, 2009 3:28 am Post subject: |
|
|
don't shorten code just for the sake of it, if you're losing clarity, something is wrong.
== 0 definitely makes more sense to read in this case.
|
|
| Back to top |
|
 |
|