|
How do I set a COleDateTime Object which is set to the current time to 5 minutes ahead of the current time.
Taking care of cases like 12th hour, 59 seconds. dates like 31st etc.
|
|
|
|
|
COleDateTime ct = COleDateTime::GetCurrentTime();
COleDateTimeSpan ts(0, 0, 5, 0);
ct += ts;
Pavel
Sonork 100.15206
|
|
|
|
|
#include <stdio.h>
#include <stdlib.h>
int main()
{
int nFibo = 0;
int *FiboArray;
int loop = 0;
printf("How many Fibonacci numbers do you want to see?\n");
scanf("%d", &nFibo);
if (nFibo == 0)
exit(0);
else
{
FiboArray =(int *)malloc(nFibo);
if( FiboArray == NULL )
printf( "Insufficient memory available\n" );
else
{
printf("0 1 ");
FiboArray[0] = 0;
FiboArray[1] = 1;
for (loop = 2; loop < nFibo ;loop ++)
{
FiboArray[loop] = FiboArray[loop-1] + FiboArray[loop-2];
printf("%d ", FiboArray[loop]);
}
printf(" \n");
}
free(FiboArray);
return (0);
}
}
<\p>
//Hi all, This little program gives me a run time error at the line that has free(FiboArray)
Does anyone know what the problem is?
thanks
|
|
|
|
|
two things :
1.
what if nFibo is 1?
FiboArray[1] = 1;
this will write outside the array.
2.
when you use malloc, you have to take into account the size of the objects you are allocating. malloc allocates BYTEs, not objects. so, to allocate nFibo int's, use malloc(nFibo * sizeof(int).
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
In addition to Chris' suggestions, you need to allocate nFibo+1 elelents.
FiboArray[0] is element #1
FiboArray[1] is element #2 so minimum allocation is 2 = (nFibo=1) + 1 (like Chris said)
FiboArray[2[ is element #3 so minimum allocation is 3 = (nFibo=2) + 1
& etc.
|
|
|
|
|
The computer user can log on Win2000 as an administrator, while
he should be forbidden to change the system time under windows 2000.
Of course we can carry this point by setting the "User Rights Assignment"
through the "Domain Controller Security Policy" tool, but how can we gain
this end through VC programing?
|
|
|
|
|
Are you asking how to prevent the system administrator from adminstering the system? Why not have the user logon as something other than Administrator? Even if you do this, what keeps the Administrator from simply resetting the right manually? (Or does it not matter).
You can post messages to any window. So if you can get the the gui of the tool you need opened, you can send messages to it and any controls in it. That gives your program control of the tool.
|
|
|
|
|
Thank you for your reply.
I am working for a special system. The user must logon as an administrator, and he can access "command console" only.
How to prevent him from changing the system time then?
|
|
|
|
|
I think you will need to set the rights using the Domain Controller Security Tool, you mentioned in your original post. I'm not familiar with that tool, but if you can figure out how to launch it from your program, if you can get the the gui of the tool you need opened, you can send messages to it and any controls in it. That gives your program control of the tool.
|
|
|
|
|
Thank you again.
You are right that I can set the rights by using the tool([Start]-[Programs]-[Administrate tools]-[Local Security Policies]-[Security Setting]-[Local Policies]-[User Rights Assignment]). I just want to restrict the user in an unvisible or hidden process. That is, we should not see the gui of the tool. How to implement it throught VC programing?
|
|
|
|
|
Hi All,
I am sending data over a (supposedly) blocking socket in a while loop but having trouble. The code works fine if I single step through code, data is sent properly, the but send fails on WSAECONNABORTED when running full speed. I am using the Dundas socket wrapper functions but tracing into the source doesn't show anything suspicious.
Anybody have any ideas?
Robert Boll
|
|
|
|
|
Do you send data to a server you designed or a public server?
If you designed the server, then you should check your server code.
Kuphryn
|
|
|
|
|
Its much easier to find the problem when you are looking in the right place.
Thanks so much.
Robert.
|
|
|
|
|
Does the server recieve data in Big Endian or little Endian. If I recall correctly, the byte order for MFC is little Endian, but if you are connecting to a Unix box or a Mac they might expect to recieve the data in Big Endian byte order.
|
|
|
|
|
I put a bitmap on my dialog box as a background, but it is covering the buttons. Is there anyway to send the bitmap back so the buttons are in front in VC++ 6.0 ? Thanks in advance friends, and C++ experts!
|
|
|
|
|
Draw the bitmap yourself in WM_ERASEBKGRND. There are exampes here on CP.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
|
I didn't know the tab order controlled the drawing order ?
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining.
Said by Roger Wright about me.
|
|
|
|
|
The tab order is set by moving their order in the rc file, as you've suggested he do.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Oh, ok learn something new everyday,
[embarassed]
I'd always wondered where the Tab order was stored.
[/embarassed]
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining.
Said by Roger Wright about me.
|
|
|
|
|
Colin^Davies wrote:
I didn't know the tab order controlled the drawing order ?
The tab order changes the order in the *.rc files. And for non-tab-stop controls like the static control, it serves as a mechanism by which we can simulate a bring-to-front for dialog controls.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Colin^Davies wrote:
I didn't know the tab order controlled the drawing order ?
Technically, the tab order is the Z-order of the controls, and that controls the drawing order. (It's also why you can use SetWindowPos() to change the tab order.)
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Try altering the order it appears in your rc file, if using MFC, or in creation if standard.
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining.
Said by Roger Wright about me.
|
|
|
|
|
I want to mess around with the Linker settings from a Macro, but I can't seem to find the interface to use. Here's what I have now. I can successfully enumerate down and retrieve the release Configuration object. But I don't know where to go from here. Has anybody done something like this before?
Sub SetupRelease()
Dim proj As Project
Dim confs As Configurations
Dim conf As Configuration
Dim linker As VCLinkerTool
For Each proj In Application.Solution.Projects
confs = proj.ConfigurationManager().ConfigurationRow("Release")
For Each conf In confs
' I don't know how to get the VCLinkerTool from here
Next
Next
End Sub
|
|
|
|
|
I have written an handler when the user presses the left mouse button in the list control.
I am doing the following in the handler code
{
Invalidate();
HWND hWnd1 = ::GetDlgItem (m_hWnd,IDC_LIST2);
LPNMITEMACTIVATE temp = (LPNMITEMACTIVATE) pNMHDR;
RECT rect;
//get the row number
nItem = temp->iItem;
..
..
..
}
nItem is having -1 and not a valid row number?
Could anyone tell why it is so.
Thanks
|
|
|
|