You can not define _UNICODE. How did you determine that szExeFile is a WCHAR? Win32::Process::List compiled without errors or warnings for me.
That's why I confused. W::P::L compiled successfully for me too. what I determine the szExeFile's type is using printf as the test code below:
#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 _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 he
+re
} ;
CloseHandle( hProcessSnap );
return( TRUE );
}
My question is, I think simply changing WCHAR to SV is wrong. but the fact blow me, W::P::L compiled,and works fine.