|
Thanks, But I need to know How to use my CreateProcess function from the service so that it can read or write any loaction on the system.
|
|
|
|
|
Hi,
The reason why you are able to access the drive in when you normally run the executable from command prompt is that when u are executing it as normal exe you are running that application in the User account from which you have logged on . And that user has the privileges to access the network. But , when you install the executable as a service , by default if you see in the task manage it runs under 'SYSTEM' account . And you might be knowing that the 'SYSTEM' doesn't have rights to access network resources.
There can be two solutions to this problem.
1. As Sauro Viti already pointed out in the link he gave you , to map the drive as persistent.
2. There is one more approach that can be followed. If you open the service manager by typing in the 'services.msc'you can go to your service and in the properties of your service there is a logOn tab where you can specify the account as any other account than 'System' you can either start service from your own logged on user account or through 'Network Service'. When you do this .. the service can access any network component and drive even if they are not persistent also.
To achieve this programmatically you can look into 'CreateService' function at
http://msdn.microsoft.com/en-us/library/ms682450(v=vs.85).aspx and can set the parameter 'lpServiceStartName ' to 'NT AUTHORITY\NetworkService'. This will start your service under 'Network Service' account and then you are done.
3. You can also try by making the service as interactive by specifying SERVICE_INTERACTIVE_PROCESS in the servicetype parameter flag of your CreateService() function but this will be limited only till XP as Vista and 7 donot support this feature.
Hope the solutions help you.. Let me know if this worked for you .
-Kushagra
|
|
|
|
|
Hi Kushagra,
Thanks a lot for your help. I will just try with the methods you described.
I have also came accros some posts where it is said to use CreateProcessAsUser function to launch the child process. But I could find a proper code to get the "Token Handle" to be used as a parameter to this function. Could you please help me in this area. ?
with thanks and regards
Ranojay
|
|
|
|
|
Ranojay wrote: I have also came accros some posts where it is said to use CreateProcessAsUser function to launch the child process. But I could find a proper code to get the "Token Handle" to be used as a parameter to this function. Could you please help me in this area. ?
For doing this .. First you will have to make the service as 'INTERACTIVE' as I mentioned in the earlier reply. Then if u are using the function CreateProcessAsUser() you will have to fallow the process as mentioned in this link :
http://msdn.microsoft.com/en-us/library/aa379608(VS.85).aspx
This should solve your problem.
-Kushagra
PS: If you like my Answers .. Please rate them ... That will give me a lot of confidence
modified on Wednesday, September 29, 2010 9:23 AM
|
|
|
|
|
Hi all,
I dnt know whether its a right forum for this question.If any one can help me it will be helpful to me.
I am drawing a rectangle using LeadTools.
Here is the code :
void CImageViewerView::OnAnnotationRectanle()
{
m_ImageViewer.SetAction(CONTAINER_ACTION_ANNOTATION_RECTANGLE,CONTAINER_MOUSE_BUTTON_LEFT,FALSE);
m_ImageViewer.EnableActionCallBack(TRUE);
m_ImageViewer.SetAction(110, CONTAINER_MOUSE_BUTTON_RIGHT, DCACTION_ACTIVEONLY);
}
How can i get the co-ordinates
1) m_ImageViewer.SetAction : Sets the rectangle for left mouse button.
2)m_ImageViewer.EnableActionCallBack: Returns if the rectangle is drawn.
3)I want to use GetAnnotationContainer() for returning the co-ordinates.
m_ImageViewer.SetAction(110, CONTAINER_MOUSE_BUTTON_RIGHT, DCACTION_ACTIVEONLY);
This is working fine for me,I am changing the rectangle action to Right Mouse button
Here is the API :
L_INT GetAnnotationContainer(L_INT nCellIndex,L_INT nSubCellIndex,HANNOBJECT * PhAnnContainer,L_UINT uFlags);
I have this in .h file
typedef struct tagDISPCONTAINERCELLINFO
{
L_UINT uStructSize;
L_HDC hDC;
L_INT nCellIndex;
L_INT nSubCellIndex;
RECT rcRect;
RECT rcBitmapRect;
L_INT nX;
L_INT nY;
}
DISPCONTAINERCELLINFO, * pDISPCONTAINERCELLINFO;
When i am trying to use the same
pDISPCONTAINERCELLINFO pCellInfo;
void CImageViewerView::OnAnnotationRectanle()
{
m_ImageViewer.SetAction(CONTAINER_ACTION_ANNOTATION_RECTANGLE,CONTAINER_MOUSE_BUTTON_LEFT,FALSE);
m_ImageViewer.EnableActionCallBack(TRUE);
m_ImageViewer.SetAction(110, CONTAINER_MOUSE_BUTTON_RIGHT, DCACTION_ACTIVEONLY);
m_ImageViewer.GetAnnotationContainer(pCellInfo->nCellIndex, pCellInfo->nSubCellIndex, &PhAnnContainer, CONTAINER_ACTION_ANNOTATION_RECTANGLE);
}
But i am getting memory cannot read for pCellInfo->nCellIndex (Run Time error)
If any one knows what i am doing wrong,please help me
Thanks
raj
|
|
|
|
|
You're accessing memory through an uninitialised pointer (pDISPCONTAINERCELLINFO pCellInfo; ). In this situation the behaviour you're getting is exactly what's expected.
Steve
|
|
|
|
|
Hi,
I corrected with
DISPCONTAINERCELLINFO pCellInfo;
m_ImageViewer.GetAnnotationContainer(pCellInfo->nCellIndex, pCellInfo->nSubCellIndex, &PhAnnContainer, CONTAINER_ACTION_ANNOTATION_RECTANGLE);
But still i am no tgetting any coordinate values.
Any idea will be helpful
Thanks
Raj
|
|
|
|
|
Here's the API you gave in an earlier post:
Here is the API :
L_INT GetAnnotationContainer(L_INT nCellIndex,L_INT nSubCellIndex,HANNOBJECT * PhAnnContainer,L_UINT uFlags);
I have this in .h file
typedef struct tagDISPCONTAINERCELLINFO
{
L_UINT uStructSize;
L_HDC hDC;
L_INT nCellIndex;
L_INT nSubCellIndex;
RECT rcRect;
RECT rcBitmapRect;
L_INT nX;
L_INT nY;
}
DISPCONTAINERCELLINFO, * pDISPCONTAINERCELLINFO;
And here's the updated code you just posted (I've corrected the incorrect escaping):
DISPCONTAINERCELLINFO pCellInfo;
m_ImageViewer.GetAnnotationContainer(pCellInfo->nCellIndex, pCellInfo->nSubCellIndex, &PhAnnContainer, CONTAINER_ACTION_ANNOTATION_RECTANGLE);
The pCellInfo variable is still not inititalised! In fact this code is worse, it will not even compile: pCellInfo is not a pointer (despite it's name suggesting it is) but is used as if it is (pCellInfo->nCellIndex ).
Steve
|
|
|
|
|
Using a COutlookBar, and adding a different set of controls each time the app runs, depending on user's access rights. Somewhere in the bowels of the MFC class is code that saves the window state in the registry and retrieves it when you run the app again, so as to reposition the docked panes etc. as the user left them. This works OK if the set of controls added to the outlook bar is the same as the last time the app was run; however, if not, the code seems to screw up the calculation of the window size or position, with the result that it fails to show the outlook bar at all.
Is there a recommended way to add/remove controls from the outlook bar, to achieve what I need? Hiding the controls works as far as displaying the bar is concerned, but it also means that the user can enable them again from the 'Navigation Pane Options' button, so that's not an option.
|
|
|
|
|
I'm not sure this is possible - is there a way that I can do the following - I'd like to modify the text in the the filename Edit box of a File Save dialog in a 3rd party program (for which I don't have the source code). Could I do this by using Spy++ to get the handle to the dialog and the Edit box, then use my code to modify the text?
Thanks!
Tom
|
|
|
|
|
Yes, I think it is called automation. It takes figuring the dialog's handle, the textbox's handle (or its tab position), then sending some characters using SendKeys. I tend to identify the foreground window (using user32's GetForegroundWindow) to improve the reliability.
Warning: whatever you do it won't be fool proof (unless you can use an API the app provides). There always is a possibility something unexpected happens, e.g. another dialog pops up informing the user about an exceptional situation; and the interactive user might be interfering too.
[ADDED]
Automation may also stop working when the system load changes dramatically (so operations suddenly exceed the timeouts you have installed), when the app's settings (or the system's regional settings) get changed, when a new version of the app gets installed.
[/ADDED]
|
|
|
|
|
Thanks, I'll give it a try! It's just a "hobby" application that I want to write, not critical if it fails sometimes...
Thanks,
Tom
|
|
|
|
|
there was a way to do it in vc 6...i forget how...
the trouble i am having is the debug works fine but the release crashes.
so i want to step into the release version....
it could be done in vc6...how to do it in vs2008?
thanks!
|
|
|
|
|
You can debug a release version but the code tends to have been moved around a bit by the compiler. Make sure you're building with debug information (right click on project->settings, C++->general, debug information format set to program database) and then copy the PDB file to the directory you're running your code from. If it doesn't remove the bug try disabling optimisation as well - it makes debugging easier.
Cheers,
Ash
|
|
|
|
|
thank you Ash!
I did what you said...
Make sure you're building with debug information (right click on project->settings, C++->general, debug information format set to program database)
then I set a breakpoint in the release version of the code (in the IDE) and ran it expecting it to stop at the breakpoint. But it did not and the breakpoint did not look colored anymore. It just ran on and crashed.
I would like the code to stop executing at the breakpoint so I can step in and proceed line by line.
thanks!
|
|
|
|
|
In addition, that Ash said, please check the following :
- C++\Optimization: NO
- Linker\GenerateDebugInformation: YES
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
Eugen Podsypalnikov wrote: - C++\Optimization: NO
Generally, you go to the trouble of debugging a release version because the debug version is working and you want to see why optimizations are screwing up the release version. If you turn off optimizations, you have the debug version.
Once you agree to clans, tribes, governments...you've opted for socialism. The rest is just details.
|
|
|
|
|
Wow...
Thank you !
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
Thank you!! Thank you!! Thank you!!!
I can step in now!
|
|
|
|
|
|
Very informative!
Reading them now.
Many thanks 
|
|
|
|
|
you're welcome.
|
|
|
|
|
how can you modify modal dialog buttons to look like xp style in mfc?
is there a class in mfc that does that for you?
|
|
|
|
|
|