Importing Source code snippets [message #725272] |
Wed, 14 September 2011 11:57 |
Ungeiist Messages: 3 Registered: September 2011 |
Junior Member |
|
|
Hi, I'm having trouble understanding how to take code, copied from a forum, and put it into eclipse.
For example I copied this example program from a forum but now I have no idea how to compile and run it using eclipse on my own machine.
Should I create a new project and just insert this code somewhere?
#include <windows.h>
void suicide(unsigned long exitcode) {
HMODULE hModule;
char szModuleName[MAX_PATH];
hModule = GetModuleHandle(0);
GetModuleFileName(hModule, szModuleName, sizeof(szModuleName));
if (GetVersion() & 0x80000000) {
// windows 9x,ME
__asm {
lea eax, szModuleName
push exitcode
push 0
push eax
push ExitProcess
push hModule
push DeleteFile
push FreeLibrary
ret
}
} else {
// windows NT,2K
CloseHandle(4);
__asm {
lea eax, szModuleName
push exitcode
push 0
push eax
push ExitProcess
push hModule
push DeleteFile
push UnmapViewOfFile
ret
}
}
}
void main(int argc, char ** argv) {
suicide(0);
}
Any help is greatly appreciated.
Sorry if this is a stupid question but I'm very new to this
Thanks
|
|
|
Re: Importing Source code snippets [message #725306 is a reply to message #725272] |
Wed, 14 September 2011 13:16 |
|
On 2011.09.14 5:57, Ungeiist wrote:
> Hi, I'm having trouble understanding how to take code, copied from a
> forum, and put it into eclipse.
> For example I copied this example program from a forum but now I have no
> idea how to compile and run it using eclipse on my own machine.
> Should I create a new project and just insert this code somewhere?
>
>[snip]
No, this isn't a stupid question at all. Many have probably different
solutions to this.
For my part, I usually keep a project in any workspace where I'll need
it named TryStuff. When I want to try out some solution or some quick
code snippet such as this one, I create a class ('cause I'm a Java guy
and no longer a C guy) in that project to try it. That way, I'm not
creating a whole new project each time.
There are probably more sophisticated solutions and these (as well as my
own) may vary for C/C++ development.
In your case, being a C (and Windows) guy, you might find more precise
help on the Eclipse CDT forum. (I have not personally used Eclipse for C
development.)
|
|
|
Re: Importing Source code snippets [message #725536 is a reply to message #725306] |
Thu, 15 September 2011 06:19 |
Ungeiist Messages: 3 Registered: September 2011 |
Junior Member |
|
|
Russell Bateman wrote on Wed, 14 September 2011 09:16On 2011.09.14 5:57, Ungeiist wrote:
> Hi, I'm having trouble understanding how to take code, copied from a
> forum, and put it into eclipse.
> For example I copied this example program from a forum but now I have no
> idea how to compile and run it using eclipse on my own machine.
> Should I create a new project and just insert this code somewhere?
>
>[snip]
No, this isn't a stupid question at all. Many have probably different
solutions to this.
For my part, I usually keep a project in any workspace where I'll need
it named TryStuff. When I want to try out some solution or some quick
code snippet such as this one, I create a class ('cause I'm a Java guy
and no longer a C guy) in that project to try it. That way, I'm not
creating a whole new project each time.
There are probably more sophisticated solutions and these (as well as my
own) may vary for C/C++ development.
In your case, being a C (and Windows) guy, you might find more precise
help on the Eclipse CDT forum. (I have not personally used Eclipse for C
development.)
Thanks
|
|
|
(no subject) [message #725538 is a reply to message #725306] |
Thu, 15 September 2011 06:19 |
Ungeiist Messages: 3 Registered: September 2011 |
Junior Member |
|
|
Russell Bateman wrote on Wed, 14 September 2011 09:16
> On 2011.09.14 5:57, Ungeiist wrote:
> > Hi, I'm having trouble understanding how to take code, copied from a
> > forum, and put it into eclipse.
> > For example I copied this example program from a forum but now I have no
> > idea how to compile and run it using eclipse on my own machine.
> > Should I create a new project and just insert this code somewhere?
> >
> >[snip]
>
> No, this isn't a stupid question at all. Many have probably different
> solutions to this.
>
> For my part, I usually keep a project in any workspace where I'll need
> it named TryStuff. When I want to try out some solution or some quick
> code snippet such as this one, I create a class ('cause I'm a Java guy
> and no longer a C guy) in that project to try it. That way, I'm not
> creating a whole new project each time.
>
> There are probably more sophisticated solutions and these (as well as my
> own) may vary for C/C++ development.
>
> In your case, being a C (and Windows) guy, you might find more precise
> help on the Eclipse CDT forum. (I have not personally used Eclipse for C
> development.)
Thanks :)
|
|
|
Powered by
FUDForum. Page generated in 0.03316 seconds