|
Actually integer is machine dependent, say for Turbo C it is 16 bit. For Visual C it is 32 bit. So you cannot write a portable with int since it changes its behavior with the machine.
Please refer this article to get more info [^]
Величие не Бога может быть недооценена.
modified on Wednesday, October 28, 2009 6:38 AM
|
|
|
|
|
Hi,
I am creating a COM object in VC++ to take the snapshot of the screen (PrintScreen key functionality) and to send it to the default printer. I could get the screen shot by using the keybd_event() in to the clipboard but I could not find a proper way to print the screen to the default printer.
Can anybody help me in resolving this. Could any one send me the code snippet to do this in ATL COM application?
With Regards,
Abraham Chethuvelil
|
|
|
|
|
|
Thanks David,
Let me ask you one doubt from your code.
You have taken the default printer to the Handle and in the calling area, you have used it with GetPrinter(). I require the function which will work same as the code snippet in VB.
Dim PauseTime, Start
Clipboard.Clear
Call PrintScreenApp
Dim dataPic As Picture
PauseTime = 20 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
Set dataPic = Clipboard.GetData()
DoEvents ' Yield to other processes.
If dataPic <> 0 Then
Printer.PaintPicture dataPic, 0, 0, (Printer.Width - 400)
Printer.EndDoc
Clipboard.Clear
Exit Do
End If
Loop
Set dataPic = Nothing
Can you please help me?
With Regards,
Abraham Jose
|
|
|
|
|
Arun Abraham Jose wrote: Dim PauseTime, Start
Hi Abraham,
Unfortunately VB6 code looks like egyptian hieroglyphics to me. I have always wondered what a Dim is. I searched codeproject and found some C++ code you could copy and paste.
Easy to use class for ScreenCapture to printer[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Hi,
Exactly there lies the problem, some of the functions we found in these samples will not work in ATL application, if I say for example, 'CBitMap' used in the last link you provided is giving error when I use it in my application, but when I try to include afxwin.h, it gives a fatal error saying Windows.h already exists.
When I search through sites, all of them are either used in normal Single Document or Dialog based applications or coded to help in UI based applications. When I use these code snippets in my application it will either throw exceptions or will show syntax errors
Please provide me a solution to this.
With Regards,
Abraham Jose
|
|
|
|
|
Arun Abraham Jose wrote: Please provide me a solution to this.
The MFC framework is nothing more than a thin wrapper around the Win32 equivalents. The CBitmap Class [^] is nothing more than a wrapper around the BITMAP Structure[^].
Anyway have a look at the Capturing an Image[^] sample provided by Microsoft. The CaptureAnImage function in that example is not using any MFC. I'm sure with all the code you are being provided that you can get something working.
Best Wishes,
-David Delaune
|
|
|
|
|
Hello All,
I have a service and I want to spawn a process through it but only at the time when I found no user logged on to the machine. i.e I have a function which is executed on a timely basis and it should check the number of active user sessions on that machine and if the count comes to be zero it should spawn the process in system account .
Regards,
Kushagra
|
|
|
|
|
|
Thanks man ,
That is waht I was looking for
Kushagra
|
|
|
|
|
Beside the solution provided by the poster before, here is an alternative idea.
Catch the SERVICE_CONTROL_SESSIONCHANGE event in your service (only with HandlerEx possible).
This event is triggered every time a user logs on / logs off / remote log on / remote log off etc.
Combined with the solution before you will be able to start your app at the log off of the last user and
stops or pauses if an user logs in.
Greetings
Covean
|
|
|
|
|
NetWkstaUserEnum
The NetWkstaUserEnum function lists information about all users currently logged on to the workstation. This list includes interactive, service and batch logons.
I want only the list of interactive users and not service and batch logons , can you please let me know the way to do it ???
|
|
|
|
|
Maybe try for every logged-in-user you enumurate NetUserGetInfo with level 23 where flag is UF_NORMAL_ACCOUNT.
|
|
|
|
|
How is that suppose to work? Nearly all user accounts are UF_NORMAL_ACCOUNT regardless of session ID.
Best Wishes,
-David Delaune
|
|
|
|
|
Sorry but I just hoped that this will work. I hadn't the time to test.
But as I saw you had an better idea I hope that works.
Regardless of this, I also would think about the idea I posted at first.
Greetings
Covean
|
|
|
|
|
Can you explain this with an example ? My goal is simple I want to count the number of active sessions on a server or machine which will be my own base machine , if count comes 0 I will execute my script else I wont.
Kushagra
|
|
|
|
|
|
Finally figured it how it has to be done :
Posting my anwer here :
#include <windows.h>
#include <stdio.h>
// The following constant may be defined by including NtStatus.h.
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
// The LSA authentication functions are available in Unicode only.
#define UNICODE
int _cdecl main()
{
PLUID sessions;
ULONG count;
NTSTATUS retval;
int i;
retval = LsaEnumerateLogonSessions(&count, &sessions);
if (retval != STATUS_SUCCESS) {
wprintf (L"LsaEnumerate failed %lu\n",
LsaNtStatusToWinError(retval));
return 1;
}
wprintf (L"Enumerate sessions received %lu sessions.\n", count);
// Process the array of session LUIDs...
for (i =0;i < (int) count; i++) {
GetSessionData (&sessions[i]);
}
// Free the array of session LUIDs allocated by the LSA.
LsaFreeReturnBuffer(sessions);
return 0;
}
it works ffine...SOme body please mark this answer and close the threda as I cant
Kushagra
|
|
|
|
|
Hi Experts,
Is there any windows C++ functions which can be used to get the
folder or file name that is selected either by right or left
click.
Got some hints in the forum but that only prints the type of mouse
event like eg Left click or right click. It uses "UserActivityHook"
to know the typeof event. What I would like to know is the file or
folder name on which the mouse is clicked.
Thanks.
|
|
|
|
|
Member 2114852 wrote: What I would like to know is the file or
folder name on which the mouse is clicked.
You may have to work this out for yourself. When the mouse event fires the screen position of the mouse is captured. You then take that position (x, y), convert it if necessary to be relative to your own window, and figure out which item it is pointing to. If you are using ListView, TreeView etc then there are other events where this conversion is done for you and the actual subitem reference is returned.
|
|
|
|
|
Just refer the Shell APIs for those notification refer ChangeNotifiyWatcher.zip in the below link. [^]
Величие не Бога может быть недооценена.
|
|
|
|
|
Are you referring to a folder selected in Windows Explorer?
|
|
|
|
|
Yeah.. I am referring to a folder selected in windows explorer.
|
|
|
|
|
|
You know that helper macro in MFC (pardon my ignorance but I haven't used MFC in probalby 6-7 years) that is used for creating object at runtime, used in Views, I think it's RUNTIME_CLASS or something???
What is the name of the closest pattern for that implementation, obviously it's not a singleton and it's not quite a factory either, or is it?
I am implementing (in another language) a object which does:
1. Prevents direct instantiation by virtue of a private constructor
2. The second object which is used to create the said oibject manages the instances to limit only one per class
So I get the benefits of a singleton while still honoring inversion of control or DIP. Without the global introduced using a singleton.
Cheers,
Alex
|
|
|
|