#include "stdafx.h" #include #include #include #include #include #include #include #include "XSUB.h" PerlInterpreter *my_perl; BOOL GetProcessList( ); int _tmain(int argc, _TCHAR* argv[]) { PERL_SYS_INIT3(NULL, NULL, NULL); my_perl = perl_alloc(); perl_construct(my_perl); GetProcessList( ); Sleep(10000); perl_destruct(my_perl); perl_free(my_perl); PERL_SYS_TERM(); return 0; } BOOL GetProcessList( ) { HANDLE hProcessSnap; PROCESSENTRY32 pe32; hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); pe32.dwSize = sizeof( PROCESSENTRY32 ); while( Process32Next( hProcessSnap, &pe32 ) ) { printf("process name is %s \n", pe32.szExeFile); //just print the first char of name printf("process name is %ls \n", pe32.szExeFile); // display name correctly SV* name_sv = newSV(0); sv_setpv((SV*)name_sv, pe32.szExeFile); //complain here } ; CloseHandle( hProcessSnap ); return( TRUE ); }