|
vishalgpt wrote: I found this sample in codeproject.
Then you should post your question in the forum at the end of the article where you found it. That author of the code is the best person to help you.
|
|
|
|
|
i asked it here because since long time the author had not replied to any questions in his article.
Regards,
Vishal
|
|
|
|
|
Your original message gives no clue as to why the code fails; collect some diagnostic information and maybe people will be able to make some suggestions. It may also help if you post a link to the article.
|
|
|
|
|
Subverting Vista UAC in Both 32 and 64 bit Architectures[^]
Service is installed correctly. But when i call the below code in CustomMessageSender.
OpenService(hSCM, SERVICE_NAME,SERVICE_USER_DEFINED_CONTROL);
bSuccess = ControlService(hMyService,SERVICE_CONTROL_CUSTOM_MESSAGE, &status);
bSuccess return TRUE ; But the cmd.exe is not executed as called in LaunchAppIntoDifferentSession()
|
|
|
|
|
Things to consider:
ControlService(hMyService,SERVICE_CONTROL_CUSTOM_MESSAGE, &status);
I presume this line causes ServiceControlHandler() to be called, which in turn calls LaunchAppIntoDifferentSession() which does lots of things, some of which return a result indicating success or failure. Unfortunately these results are not passed back up the line so you have no idea what happened in this function. Add some breakpoints in the LaunchAppIntoDifferentSession() function in order to find out what is happening.
|
|
|
|
|
|
Ooops! There was a small mistake in WTSGetActiveConsoleSessionID() which result in return of Session id to zero only.
Problem solved.
Regards,
Vishal
|
|
|
|
|
|
Hi all,
I am taking a picture control on the dialog.In Properties I am taking a Bitmap Image on the dialog.
I am planning to drag and drop the bitmap image to other location.But i am not able to.
I am able to get the MouseMovements(x axis,y axis),where in ,i am changing the cursor when the mouse is on the
bitmap image as shown in below function.
Please find the below code,which i am trying.
Please let me know what to do
void CLoadImageDlg::OnMouseMove(UINT nFlags, CPoint point)
{
HWND hwnd;
CString str_mousemove;
POINT p;
long int xp,yp,i;
int lParam;
i=3;
GetCursorPos(&p);
xp=p.x;
yp=p.y;
str_mousemove.Format(_T("x = %d,y=%d"),xp,yp);
CPoint ptHotSpot(500,600);
if((xp>507 && xp <696) && (yp>460 && yp<569))
{
SetCapture();
m_bCaptured=TRUE;
CPoint pointTopLeft(507);
m_sizeOffset = point - pointTopLeft;
::SetCursor(::LoadCursor(NULL, IDC_HAND));
}
if((xp<507 ||xp >696) || (yp<460 || yp>569))
{
ReleaseCapture();
}
CDialog::OnMouseMove(nFlags, point);
}
void CLoadImageDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CString str_mousemove1;
POINT p;
CDC dcMem;
int xp,yp;
GetCursorPos(&p);
xp=p.x;
yp=p.y;
str_mousemove1.Format(_T("x = %d,y=%d"),xp,yp);
if((xp>507 && xp <696) && (yp>460 && yp<569))
{
SetCapture();
m_bCaptured=TRUE;
CPoint pointTopLeft(507);
m_sizeOffset = point - pointTopLeft;
::SetCursor(::LoadCursor(NULL, IDC_HAND));
}
CDialog::OnLButtonDown(nFlags, point);
}
Can anyone please help me,how can i drag the image and drop to other location in the same dialog
Thanks in Advance
Thanks
Sharan
|
|
|
|
|
At a guess you need to implement drag and drop code for your image. Take a look at some of these links[^] for suggestions.
|
|
|
|
|
Hi
I have the following code in a DLL
{
char buffer[30].
WaitForSingleObject
strcpy(command,buffer[0])
when the object gets signaled I get a access exception
because buffer which is a local variable
is refrenced by the stack pointer
any suggestion would be helpfull
thanks
|
|
|
|
|
I'm surprised it even compiled. What you are writing is copying the string to command from the address specified by buffer[0].
strcpy(command, buffer) is probably what you wanted to write.
If that's not the problem, please give the whole code, and use code blocks to properly preserve the format
|
|
|
|
|
What is command and where have you initialized buffer ? Also, on the basis that the above code will not even compile, it is little wonder you are having problems. In future use copy and past to put your code into a question and use the "code block" button to ensure it's formatted properly.
|
|
|
|
|
When I ask what it exactly is, there are always someone told me that the wWinMainCRTStartup is the real entrance of the windows programs. And when you code with UNICODE you should set it with VC++.
I found that this wWinMainCRTStartup function was called before the global object of 'CxxxApp' being constructed. It's called before the programs running.
Can anybody tell what it exactly is? Is it involved with OS or compiler? Where does the Windows programs actually start and how? Or, are there any good books or references to be read for that?
Thanks a lot!
|
|
|
|
|
|
Tanks for answering. I'm now reading the MFC internals. I want to know the principle MFC works on.
|
|
|
|
|
Every windows application needs an entry point, to start execution. It's the first thing that gets run when windows starts a new process. This is wWinMainCRTStartup and not 'main', which is the first point of user code run, is because the C-runtime library needs to initialise before user code can be run.
If you just want a barebone executable without CRT support then you could set it to your own function via the compiler.
|
|
|
|
|
I already know that. And I just want more materials. This is the word describing. How can I get the concrete principles and explanations of the related Library sources. I searched the item on MSDN website but there is little materials of that subject.
|
|
|
|
|
It is the "initializer" and "cleaner" of the C-RunTine.
The operating system calls it with a machine code jump after loading the executable in memory and filled up the relocation table.
It takes care of the invocation of the constructors of all the global objects (since the exist "outside of main", they have to be create before main is called). It then invokes "main" (or WinMain) after unpacking the command line, and - when main returns, calls the destructor of the on-fly created static objects and the destructors of the global objects in reverse construction order, then finally, returns the main return value to the OS process who invoked the app.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
You are right. I've followed the source code in crtexe.c and watched the program's executing sequences. And can you tell me why the OS must do this? Is it because of the relocating? Thanks!
|
|
|
|
|
The reason is not because of the OS (it simply adjust the relocation table after copying the executable image in memory BEFORE jumping in it, so the exe itself has no role in that) but because of how C++ works.
Objects has constructors and destructors.
Try this
#include <iostream>
class A
{
public:
A() { std::cout << "A created" << std::endl; }
~A() { std::cout << "A destroyed" << std::endl; }
};
A global_a;
int main()
{
std::cout << "this is main" << std::endl;
return 0;
}
The output will be
A created
this is main
A destroyed
Global objects must be created/destroyed outside the scope of main.
This is not an OS requirement, but a requirement for the C++ specification.
mainCRTSturtup is the "bridge" between the OS (that has no clue about the app language specifications: it just want an address to be called) and a language like C++ that requires some code (constructors and destructors of global objects) to be executed independently of the main() function.
2 bugs found.
> recompile ...
65534 bugs found.
modified on Sunday, August 14, 2011 4:33 AM
|
|
|
|
|
Hi,
I am using a VC++ MFC app to drive Excel through OLE Automation.
I need to insert new row in the Excel.
How to acheive this?
***************
// Code Sample
***************
// excel application object
Application objExcel;
// local var
COleVariant vRet;
// range object
Range objRange;
// set the workbooks object
Workbooks objWorkbooks( V_DISPATCH( (LPVARIANT)vRet ) );
// adding the new workbook
vRet = objWorkbooks.Add( COleVariant( (long)xlWorksheet ) );
// set the workbook object
Workbook objWorkbook( V_DISPATCH( (LPVARIANT)vRet ) );
// adding the worksheet
vRet = objWorkbook.Worksheets( COleVariant( (long)1 ) );
Worksheet objWorksheet( V_DISPATCH( (LPVARIANT)vRet ) );
// get the range
vRet = objWorksheet.Range1( COleVariant( csRange ) );
objRange.AttachDispatch( V_DISPATCH( (LPVARIANT)vRet ) );
From the above code in objRange having the Row position as C8.
Here need to insert a new row.
Reg,
SPala
|
|
|
|
|
Have you tried objRange.Insert() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi David,
Thanks for your reply. I am using Excel 2007.
Yes i tried with Insert method. I don't how to give the Parameter value;
Below is my code:
csRange.Format("C%d", nRow );
vRet = objWorksheet.Range1( COleVariant( csRange ) );
objRange.AttachDispatch( V_DISPATCH( (LPVARIANT)vRet ) );
objRange.Insert(???)
**********************************
synatx for Insert:
objRange.Insert(const VARIANT &shift)
**************************************
How to give the parameter value for Insert method?
Waiting for your reply.
Thanks,
SPala
|
|
|
|
|
spalanivel wrote: How to give the parameter value for Insert method?
Have you tried something like:
objRange.Insert(COleVariant(-4121L), vtOptional);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|