DialogBoxParam() method is not invoking GUI in IE 9 or above - c++

I am VC and VC++ developer. I use VS2008.I have developed an API for capturing the fingerprint through a biometric scanner, in VC. After capturing the fingerprint, I need to display the fingerprint image to the user. So I used DialogBoxParam()method to create a GUI. I have 3 modules. First is the Core DLL, Second is the Windows Service and the Third is Scanner DLL. For capturing the fingerprint, I used to give request from core DLL to the service the will contact the Scanner and revert us back. After the response from the service I call DialogBoxParam() method to show the fingerprint GUI. I have used GetForegroundWindow() to bring the GUI to the front of the browser. In Windows 7, IE 9 or above, the DialogBoxParam() method gets failed. If I avoid GetForegroundWindow(), DialogBoxParam() method got succeeded. I cannot find the solution for this problem. Please help me in this. Below is the code to create the GUI.
*
DialogBoxParam(GetInstance(),MAKEINTRESOURCE(IDD_FEATURE_DIALOG),GetForegroundWindow(),(DLGPROC)WndProc,
NULL);
*

DialogBoxParam return -1 and GetLastError return 0 in ActiveX Control

Related

MFC application / AfxOleInit / RAPI failure with RPC server is unavailable

To implement the copy and paste functionnality in a MFC application, we invoke the AfxOleInit() method.
We also use RAPI to communicate with Windows Mobile devices.
When AfxOleInit is not used, we have no problems.
But as soon as AfxOleInit is actually executed, we reproduce the following sequence:
The mobile device is in its cradle and correctly connected via Windows Mobile Device Center (WMDC) to the PC,
CeRapiInitEx and then CeRapiUninit complete successfully
We remove the mobile from the cradle which deconnects from WMDC
We reput the mobile in the cradle and, a second time, CeRapiInitEx and then CeRapiUninit complete successfully
We remove the mobile from the cradle which deconnects from WMDC
At that moment, a message appears in the "Output" tab of Visual Studio: "the RPC server is unavailable"
We reput the mobile in the cradle and this time CeRapiInitEx fails with the return value "the RPC server is unavailable"
We have tried to put the code which contains the calls to the RAPI dll functions:
directly in a MFC application,
in a DLL,
in an ActiveX
we reproduce the error in all cases.
Note that, if this code is put in another process launched via a CreateProcess from the MFC application, there are no errors.
You can download the application which reproduces this error at the following address:http://iode-informatique.com/tests/winmob_mfc/rapi_test_app.zip
Note that if you comment the call to AfxOleInit, the error doesn't occur.
Best regards.

Can I have a COM interface in a service to be called from Windows Script Host?

My goal is to create a COM interface in my Windows local service, written with C++/MFC, whose methods could be called from a Windows Script Host JScript code running under a logged in interactive user account.
For instance, if I have a test.js that can be started with credentials of a logged in user, that does the following:
var Obj = new ActiveXObject("myservice.somename");
var Result = Obj.MyMethod("some data");
and then have MyMethod function processed in my service & return a value.
I know it's a general concept. At this stage I'm curious if such is possible (from a Windows security stand-point, i.e. calling system service from a user process) and if so, if there's any sample code that I can use as a basis for this?
I'm assuming that it must be some COM interface, right? But usually those go into a DLL. I've never tried to put them in a service.
Thank you!
I'm posting it for my own future reference, in despite of the treatment I got in the comments to my original post. It would've saved me a day of search if someone pointed me to this article...
This CodeGuru article, "COM in plain C, Part 2" explains how to create a COM interface that can be called from the Windows Script Host. His IExample2 project shows how to create an in-proc DLL that hosts the COM interface that can be called from a VBScript included in the same project. Then regiexample2 and unregiexample2 projects also show how to register/unregister the COM interface. The VBScript can be easily adjusted to work with JScript in my OP.
One word of caution though, that project is intended to be used for installation on a 32-bit OS. For 64-bit OS, you will need to build and register a 64-bit version of the in-proc COM Dll. The registration part from a 32-bit process is similar to the one shown, except that one needs to include the KEY_WOW64_64KEY flag when opening/creating registry keys.

Function is calling before service loaded

I am using blazeDS in my web application. I am facing issue with Java and flex.
I have used function to load service in creation complete event of application. And I need to get value in combo box and do some manipulation. But my function which will trace the value, is being called before service is loading. for that reason function is not returning any value.
you can overcome by doing following changes
1) call webservice in Application initizlize event
2) Call your method in ResultEvent triggers on result of Webservice
or
3) IF Still you face same issue you can call it using callLater()
or
4)IF callLater() wont work to, then you can use Event collectionchange of ListCollectionView a Parent Class of ArrayCollection, XMLListCollection
I personaly recommend DO Steps 1 and 4 Only.
Hopes that helps

Access to external window handles

I am having a problem with the program I am currently working on. It is caused by the increased security in vista/Windows 7, specifically the UIPI which prevents a window with a lower integrity level 'talking' to a higher one.
In my case, i am wanting to tell the window with a high Integrity level to move into our application, It works flawlessly on XP or windows 7 with the security off.
I have tried setting the HWND of the higher IL window directly, rather than using the findwindow() function, this works fine but the program then fails when trying to move it or generally interact with it. The windowhandle is saved by the app to be embedded and read by the app running at a lower IL.
I have also tried setting UIaccess in the manifest to TRUE and digitally signing the program but no luck.
Any ideas on how to solve this problem?
thanks.
Just thought i would follow this up for anyone who also struggled as I have finally found a way to do this.
IL = Integrity Level.
I had 2 apps, highIL.exe and lowIL.exe, the highIL wanted to find the lowIL.exe window, set it as a child window and move it into a zone created for it on the highIL.exe. This was blocked by the UIPI in vista+.
In the end i used the ChangeWindowMessageFilter method in vista and the ChangeWindowMessageFilterEx in Windows7, both found in the user32.dll. These functions allow you to poke a hole in the UIPI to allow messages that you want through.
I created a few custom messages using RegisterWindowMessage function, I used this function to register the method in both highIL and lowIL applications, the line looked a little like this:
const UINT MY_MOVEINTWINDOW_MSG = RegisterWindowMessage(_T("MyMsg.MoveWindow"));
The lowIL.exe is then able to send these messages to the highIL.exe window without them being blocked. Then it was a case of just simply adding and writing message handlers.
This method will only work if you have access to both the high and low IL.
The MSDN also has a working example of the ChangeWindowMessageFilterEx function on there Website

Generating PDF with Quick Reports behind a Delphi Web Server

I have a Delphi web server providing some web services*. One of them is supposed to generate and return a PDF report.
The PDF creation is done with a QReport that is then exported into a PDF file with the ExportToFilter procedure.
The routine works fine when called from within an application, but when called behind a TIdTCPServer, it hangs and never finishes. Debugging it, I got tho the hanging point:
(note: I'm home right now and I don't have the source code. I'll try to reproduce quickrpt.pas' source as accurrate as I can remember).
procedure TCustomReport.ExportToFilter(TQRDocumentFilter filter);
...
AProgress := TQRFormProgress.Create(Application); // Hangs on this line
AProgress.Owner := QReport;
if ShowProgress then AProgress.Show;
QReport.Client := AProgress;
...
Searching the web, I found in this page (1) the suggestion to set ShowProgress to False, and edit the code so that it does not create the progress form when ShowProgress is set to false (apparently, this is due to QReport not being threadsafe).
So, I edited the code, and now I have this:
procedure TCustomReport.ExportToFilter(TQRDocumentFilter filter);
...
if ShowProgress then
begin
AProgress := TQRFormProgress.Create(Application);
AProgress.Owner := QReport;
AProgress.Show;
QReport.Client := AProgress
end;
...
Now, the report comes out. But then the service gets to an Invalid Pointer Exception (which I can't trace). Following calls to the service complete successfully, but when I shut down the service** it starts whining again with Invalid Pointer Exceptions, then the "MyServer has commited an invalid action and must be closed" windows message, then again a couple of times more, then just the pointer exception, then comes to error 216 (which as far as I could find out, is related to Windows access permissions).
Thanks!
Update (jan 5): Thanks Scott W. for your answer. Indeed, after some research, I found another suggestion that only the main thread can access some components. So I set the QR code back to normal and called the main method from a Synchronize call inside a TThread (so that way the main thread would handle it). But I still get the same error.
You mention you were able to generate PDF as a service with QR 4. Maybe that's why it's not working for me, since I'm using QR 3. On the other hand, you don't mention if you're doing that behind a TIdTCPServer (which is my case, providing web services) or if you run it by itself (for instance, during a batch process).
Anybody knows whether my QR version might be the problem? Thanks!
* Running Delphi 7 and QuickReport 3 on a Windows XP SP2. The server is based on Indy.
** I have two versions of the server: a Windows application and a Windows Service. Both call the same inner logic, and the problem occurs with both versions.
Update (mar 8): After all, my problem was that my printing routine was in another dll, and the default memory management module is somewhat crappy. Setting the first uses of my .dpr to be ShareMem overrides the memory management module with Borland's implementation, and solved my problem.
uses
ShareMem, ...
(1): http://coding.derkeiler.com/Archive/Delphi/borland.public.delphi.thirdpartytools.general/2006-09/msg00013.html
I'm guessing that QReport.Client is used somewhere later in the code, and with your modified code no longer assigning it to AProgress, you end up with an error.
Are you sure that you have to modify the QuickReport source? I have used QuickReport in a Windows Service to generate a PDF file and then attach to email message and all worked fine without having to modify the QR source. I don't recall exactly which settings had to be made, but it was done with Delphi 6 and QR 4.06.