Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: wchar_t*, char* and perl XS

by Anonymous Monk
on Jul 13, 2012 at 02:19 UTC ( [id://981534]=note: print w/replies, xml ) Need Help??


in reply to Re: wchar_t*, char* and perl XS
in thread wchar_t*, char* and perl XS

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.

Replies are listed 'Best First'.
Re^3: wchar_t*, char* and perl XS
by bulk88 (Priest) on Jul 13, 2012 at 15:04 UTC

    My question is, I think simply changing WCHAR to SV is wrong.

    explain

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://981534]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-20 03:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found