|Problems? Is your data what you think it is?|
Win32::API Memory Exception with GetCommandLine() (which returns a static string)by Wyrdweaver (Beadle)
|on Jul 05, 2007 at 23:55 UTC||Need Help??|
Wyrdweaver has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to reparse a Win32 command line using the Win32::API to retrieve it. I've composed the function to get the command line from the examples within Win32::API, but, depending on padding of the code itself, I get an occasional GPF. I believe that Perl is trying to garbage collect the returned "static" string. Any thoughts on this or how to get around it?
I can't find any CPAN modules that retrieve the Win32 command line. So, I'm trying to roll my own. Would like to avoid going all the way to XS as I've never delved into that realm (although I have a working compilation environment with mingw).
Thanks, in advance.
Note: save the following code as "t-getCL.bat" and try "t-getCL a". For me, $string prints and then I get a GPF just before program completion. The GPF is sensitive to code size and less padding at the end of the script can make the problem go away.
Note#2: It's a .bat file to deal correctly with I/O redirection on XP.