i am C newbie, help please, i am trying to get this too work.

hi all,

I want to be able to call perl from c (eg Win32::GuiTest::FindWindowLike) 
and get this working.....basically capturing hwnd handles of open windows 
and printing them.

thanks in advance,


Jeremy A.

my code is below.
use Win32::GuiTest qw/FindWindowLike GetWindowText ShowWindow/;
use Inline C;

sub FWL
my ($zero,$class,$subclass);
return FindWindowLike($zero,$class,$subclass);





#include <stdio.h>
#include <windows.h>

static char* callback;
int isWindowOpenedHistory;
int hwnd;
int elements;
int ec;

void set_callback(char* name) {
     callback = name;

void this_test()
		isWindowOpenedHistory = malloc(5 * sizeof(&isWindowOpenedHistory));
         	hwnd = malloc(5 * sizeof(&hwnd));
         	Inline_Stack_Push(newSVpvf("Internet Explorer"));
         	perl_call_pv(callback, 0);
		elements = sizeof(*hwnd)/sizeof(int);
		for(ec = 0;ec < elements;ec++)
			printf("handle %d\n",hwnd[ec]);


9/2/2004 7:09:51 AM
perl.inline 1285 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 32
Get it on Google Play
Get it on Apple App Store

I've little idea of what you were trying to do :-)
Is the following anything like what you were after ? (Beware of line 

# BOOL EnumWindows(
#  WNDENUMPROC lpEnumFunc,  // callback function
#  LPARAM lParam            // application-defined value
#  );

# BOOL CALLBACK EnumWindowsProc(
#  HWND hwnd,      // handle to parent window
#  LPARAM lParam   // application-defined value
#  );

# int GetWindowText(
#  HWND hWnd,        // handle to window or control
#  LPTSTR lpString,  // text buffer
#  int nMaxCount     // maximum number of characters to copy
#  );

use warnings;

use Inline (C => Config =>
             LIBS => '-luser32 -lkernel32',
             BUILD_NOISY => 1,

use Inline C => <<'EOC';

#include <windows.h>

void Call_my_callback(int handle) {
      dSP ;

      ENTER ;
      SAVETMPS ;

      PUSHMARK(SP) ;
      PUTBACK ;

      call_pv("my_callback", G_DISCARD);

      FREETMPS ;
      LEAVE ;


BOOL CALLBACK EnumWindowsProc(HWND handle, LPARAM given) {

/*  This function is not accessible from perl.           */
/*  Have it do a callback to the perl subroutine         */
/*  my_callback(). This is just my (convoluted ?) way of */
/*  getting all of the handles stored into a perl array. */

      Call_my_callback((int) handle);

void enumwindows() {
      WNDENUMPROC ptr;
      LPARAM lp = 42; /* Universally meaningful number */

      ptr = EnumWindowsProc;
      EnumWindows(ptr, lp);

SV * getwindowtext(SV * a, SV * b) {
      char * buffer;
      int len = SvIV(b);
      SV * ret;

      if(b <= 0) croak("2nd arg to getwindowtext function must be 
greater than zero");

      New(1, buffer, sizeof(char) * len, char);

      GetWindowText(SvUV(a), buffer, len);
      ret = newSVpv(buffer, 0);
      return ret;


@handles = (); # global


# @handles now contains handles of all open windows.

print "Looking for IE windows\n";

for(@handles) {
    if(getwindowtext($_, 100) =~ /Internet Explorer/) {
      printf "IE Window handle: %x\n", $_;

print "Search completed\n";

sub my_callback {
     push @handles, $_[0];


The usual approach to this sort of stuff is to use the rough (but 
brilliant and effective) hack that goes by the name of Win32::API.

Anyway ... I hope there's something there that helps. But if there 
isn't, then at least I had some fun writing it :-)

Hmmm .... s/writing it/plagiarising/


9/14/2004 11:34:39 AM
Jeremy A wrote:

> hi all,
> I want to be able to call perl from c (eg 
> Win32::GuiTest::FindWindowLike) and get this working.....basically

You mean "call c from perl" right?


Patrick LeBoutillier
Laval, Quebec, Canada

9/14/2004 12:20:37 PM

Similar Artilces:

try catch not working in c#. please help
this code is in VB and it works fine, when error occur, the user will be redirect to promptUser.aspx, but when i write this code in c#, the user will not redirected. please help, please see below c# code<%@ Page Language="VB" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)Dim x As Integer = 223Dim y As String = "sdsdsd" Tryx = x / y Catch...

I cannot get my C#.NET Email Form to work on Godaddy hosting account. Please Help!!!!
Hello;   I have created a contact us page and I am using .NET Mail classes to send the form via email. However I keep getting this error when I upload my info to the hosting server... Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. Oh and yes, it wont send any emails. here is my code... using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.Web...

How do I get this to work? Please help!
Hi, I downloaded this customForm from http://www.metabuilders.com/Tools/CustomForm.aspx I have to say that I do NOT use Visual Studio - I do not own it!Currently I use Visual Web Developer Express BetaMy language is VB.NET After I extracted the zip I put the file CustomForm.cs into my bin directory and CustomForm.aspx into my application root directory. But if I call CustomForm.aspx I keep getting an error:"Parser Error Message: File or assembly name MetaBuilders.WebControls.CustomForm, or one of its dependencies, was not found." Please can anyone tell me how to "install" this CustomFor...

Type.GetType does not work in VB.NET but works in C#. VB.NET gurus Please help
Friends,   I am an experienced C# programmer who is working on a VB.NET project now. I am writing different methods covering the following functionalities 1) Take a datareader as input and return an arraylist of class object2) Take an xmlnode (received from a webservice) as input and return an arraylist of class object. The methods are generic methods which take datareader/xmlnode as first parameter and classname (string) as the second parameter. This way it will work trivially. The schema of class object matches with the input (datareader or xmlnode)In C# I used to do th...

Please help me get this to work
I must be missing something, and I think it's something simple. I have an installation of NSBS 6.5. One server, running CIFS. I have universal password enabled on both the root container and the current container. I've setup a share with appropriate file rights, but users still can't login to the server using CIFS. So I tried to set simple passwords even though I already enabled UP, iManager says I can't set the simples because UP is on. So I guess that means UP should be working. Every TID I've found basically says "make sure simple passwords are set"...

HELP!!! Please... A newbie at work
I've been charged with putting together a functional web using information from a simple Access Database (4 tables)... I'm familiar with Access and FrontPage, but not ASP... How big of a can of worms have I gotten into?Thanks, Bill to paraphrase.... "Poop happens" Forrest Gump are you fimilar with any coding language, vb, c, java? It is not very difficult to learn ASP .NET. You need to decide which language you want to use VB or C#. If you are new to programming go for VB .NET. It is very easy to learn. Also you need to decide whether you want to use Visual Studio or not...

WebParts - Strange - I have drag and drop working in firefox and safari but can't get it to work in ie
Hi Guys, I've run into an issue with webparts:  Using asp.net 3.5 on iis 6 with the AjaxControlToolkit-Framework3.5SP1, Browsing using ie8 in compatiblitiy mode on Windows 7 beta (but also tested in vista) I have managed to get it so that drag and drop works in firefox and Safari, using Microsoft.Web.Preview.UI.Controls.WebParts however when I view the page in ie the drag drop functionality is somewhat lost - I can still drag the items to another webpartzone, but once you mouse down to drag, the webpart does not follow the mouse - it stays put until you release over another zone...

Please Help.. Can't get ASP.NET App to Work on Web Server, works on local system
I have an application I developled for a shopping cart function using Wrox ASP.NET book as a guide. I have everything working great on my local system using SQL 2005 Express. When I move the app to an IIS 6.0 Web Server with SQL 2005 Express installed I get the following error. Line 103:    Public Overridable Property Cart() As Wrox.Commerce.ShoppingCartLine 104:        GetLine 105:            Return CType(Me.GetPropertyValue("Cart"),Wrox.Commerce.ShoppingCart)Line 106:   ...

Having problems on set up, I keep getting this message. I tried many times. Please Help! :) Or can I get Thunderbird 1.5 back?
Name: Helga Email: sayuridothmatgmaildotcom Product: Thunderbird Summary: Having problems on set up, I keep getting this message. I tried many times. Please Help! :) Or can I get Thunderbird 1.5 back? Comments: Error opening file for writing: \r\n\r\nmozMapi32.dll\r\n\r\nClick Retry to try again, or\r\nCancel to stop the installation. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070515 Firefox/ ...

I'm getting the access denied error in an iframe and have read stuff and i still can't get it to work! PLEASE HELP ME
 so i went and downloaded the new ajax toolkit 10920 from codeplex. I was still getting the error so i found this i've just read http://blogs.msdn.com/delay/archive/2007/02/05/safely-avoiding-the-access-denied-dialog-how-to-work-around-the-access-denied-cross-domain-iframe-issue-in-the-ajax-control-toolkit.aspx I went to edit common.js as instructed but it aslready has the lines added, and still causes this error. I am trying to use the CollapsiblePanelExtender in an iframe where the parent is not the same domain as the child. What else should i do? Thanks lots in advance &n...

Help getting IIS to work, please
I installed IIS on server 2003. This server sits behind our firewall and will serve intranet only.I put a page called default.html in the inetpub/wwwroot folder. (Once  I get this working I have a whole ASP.NET app to move to it.)when i browse to the servers address i get the page that says under construction, not my default.html page. When i browse to the ip/default.html i get a page that says Connection Interrupted. any ideas what is happening?Thanks!   update: now i added another page called test.htm and I get an error that says you are not authorized to view this page did ...

Please help a newbie to get started
I'm sorry if I ask some stupid questions. I'm a complete newbie to SQL Server and DNN. When I tried to install a clean copy of DNN, I did following steps. Please tell me which step is wrong or I missed something. Thank you. 1. Create a new SQL Server registration named MYCOMPNAME. 2. Create a new database named DotNetNuke. 3. Create a new SQL account with userid MYNAME password MYPASS. 4. Assign user MYNAME to the DotNetNuke database and let MYNAME have all the rights possible. 5. Make sure that MYCOMPNAME server use Authentication: SQL Server and Windows. 6. UnzipDNN 2.0 b...

Inline C# to VB conversion help please
 Hi, Could some one help me translate this inline code used in a Gridview TemplateField in a C# application to VB.net?<%# GetUser((AuthorizationRule)Container.DataItem) %>I tried this but I get an error:<%#GetUser(DirectCast(Container.DataItem, AuthorizationRule))%> Try using conversion tool available at: http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx What error do you get?---------------------------------------MCP - Web Based Client Development .NET 2.0  The error says: AuthorizationRule is a type and cannot be used as an expression. Any ideas? T...

Help me get my wireless adapter to work please?
I have an Acer Aspire 5000 with AMD Turion, 1.60gHZ and 896mb of ram. I am using the Broadcom 802.11G Network adapter. This is my 2nd linux distro. I got it to work on Ubuntu but I had to do a lot but I cant remember the steps. I know it can work on suse, I just installed it yesterday and it looks promising. Useless without internet though. Help me get it to work. Im not a noob when it comes to computers but not that expert at linux. I can use the terminal ok and I am familiar with a few commands. Thanks in advance. -- Felliph3 -------------------------------------------------...

Web resources about - i am C newbie, help please, i am trying to get this too work. - perl.inline

Newbie - Wikipedia, the free encyclopedia
It can have derogatory connotations, but is also often used for descriptive purposes only, without a value judgment. The term's origin is uncertain. ...

Facebook To Credits Newbies: Buy $1, Get $4 Free
Facebook has duly noted developers’ gripes that Credits hadn’t been reeling in enough users, and has quickly come up with a promotion to remedy ...

The Mary Sue - This week's Battlestar Galactica newbie... - Facebook
This week's Battlestar Galactica newbie recap, in which the pain just keeps on coming.

Say Hi to Nine of Our Newest Newbies
The year is half over, and we’re still hiring like crazy. This year we’ve added 22 associates, which means our employee count has increased by ...

Occupy Wall Street Newbie Flyer Pg 1 - Flickr - Photo Sharing!
Translated from the original Arab Spring fliers and updated for the current action. A great flier to hand out to new protesters or others. There ...

Dan Newbie - YouTube
Howdy! My name is Dan Newbie and I make videos For collaborations, media and business inquiries, please contact via email at: dannewbie@gmail.com ...

Newbie of the Day: President Obama Joins Twitter, Jokesters and Trolls Respond
Well, well, well… look who finally decided to show up. President Obama has finally joined the Twitterverse (6 years after being sworn into office) ...

Newbies to get crash course in political operations at 'senator kindy'
They're calling it ''senator kindy''. Twelve new senators will gather in Parliament House late next week for a training session before the new ...

Bombers look to newbie Kommer
Bombers enter opener against Adelaide with almost a full line-up from which to choose.

ABC collapse serves as learning experience for childcare newbies
''This is a business subsidised by government - how can it be unprofitable?'' wailed ABC Learning's former chairwoman, Sallyanne Atkinson soon ...

Resources last updated: 11/21/2015 7:46:27 AM