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.

In reply to Re^2: wchar_t*, char* and perl XS by Anonymous Monk
in thread wchar_t*, char* and perl XS by xiaoyafeng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.