With a couple of minor changes, your code compiles and runs for me:
///#include "stdafx.h"
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "perl.h"
#include "EXTERN.h"
#include "XSUB.h"
PerlInterpreter *my_perl;
BOOL GetProcessList( );
int main(int argc, TCHAR* argv[]) {
PERL_SYS_INIT3(NULL, NULL, NULL);
my_perl = perl_alloc();
perl_construct(my_perl);
GetProcessList( );
perl_destruct(my_perl);
perl_free(my_perl);
PERL_SYS_TERM();
return 0;
}
BOOL GetProcessList( ) {
HANDLE hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
+, 0 );
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof( PROCESSENTRY32 );
while( Process32Next( hProcessSnap, &pe32 ) ) {
SV* name_sv = newSV(0);
printf("process name is %s \n", pe32.szExeFile);
sv_setpv((SV*)name_sv, pe32.szExeFile);
}
CloseHandle( hProcessSnap );
return( TRUE );
}
Compile & link:
C:\test>cl /W3 /I C:\perl64\lib\CORE junk.c C:\perl64\lib\CORE\perl510
+.lib
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.21022.08 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
junk.c
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
/out:junk.exe
junk.obj
C:\perl64\lib\CORE\perl510.lib
And run:
C:\test>junk.exe
process name is [System Process]
process name is System
process name is smss.exe
process name is csrss.exe
process name is wininit.exe
process name is csrss.exe
process name is services.exe
process name is lsass.exe
process name is lsm.exe
process name is svchost.exe
process name is winlogon.exe
process name is svchost.exe
process name is svchost.exe
process name is svchost.exe
process name is svchost.exe
process name is audiodg.exe
process name is SLsvc.exe
process name is svchost.exe
process name is svchost.exe
process name is spoolsv.exe
process name is dwm.exe
process name is taskeng.exe
process name is Core Temp.exe
process name is speedfan.exe
process name is taskeng.exe
process name is procexp64.exe
process name is SearchIndexer.exe
process name is svchost.exe
process name is cmd.exe
process name is mobsync.exe
process name is TextPad.exe
process name is LogonUI.exe
process name is cmd.exe
process name is cmd.exe
process name is calc.exe
process name is opera.exe
process name is explorer.exe
process name is TOTALCMD.EXE
process name is firefox.exe
process name is cmd.exe
process name is junk.exe
See how you get on with my version?
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.