|
Hello everybody,
I created a service which runs nicely on my local machine.
If I like to test an existence of a file, which is located on a network-folder (net use g: \\...)
then the function _access returns me -1 (not exists).
If I call exactly the same function with the same filename in a standard application (not as a service)
then all works fine.
Is it an access-security problem, or do I use simply the wrong function to test the existence of a file?
(I don't wanted to use a fopen,fclose)
Big thanks for any ideas
|
|
|
|
|
what account is your service running under - default localsystem ?
if so, you'll need to change that so that the account you run under has network access (localsystem by default does not have network access, this includes shares iirc).. create a dedicated account for your service, give it the correct access, its better than localsystem
(if you google around a bit you should find more pointers on the same)
'g'
|
|
|
|
|
If your service runs under the local system/local service account, it has no rights to access network resources.
Try the network service user or create a new user and assign the login to this service.
Greetings
Covean
|
|
|
|
|
Big thanks for your replies.
That seems logic, but it doesn't work ... it's seriously a configuration problem.
I'll make a workaround
Thanks you two
|
|
|
|
|
Try to see what GetLastError returns immediately after the call to __access, it might tell you something. There's a tool in Visual Studio that will give you the error text for each error id.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hello
I want to make a timer in maze.The timer should countdown to reach 0 and if the player doesn't reach to end he/she lose the game.
I want to denote that if player reach to end timer should stopped working.
How can I do it?
Thanks anyone help me.
|
|
|
|
|
I hope that you have the code for your "maze".
What kind of application is it? Assuming your main thread has a message pump, you could run a timer on a separate thread, and have it post a message to the main thread after the time is over. There may be other messages to be processed in the queue, but then again, Windows isn't an RTOS...
Workout progress:
Current arm size: 14.4in
Desired arm size: 18in
Next Target: 15.4in by Dec 2010
Current training method: HIT
|
|
|
|
|
|
Create a secondary thread with a CTimer and a countdown counter; I don't think this is much difficult.
At each "pulse" (either compare delay or Sleep), send a message to the main application thread to display the time left and when the countdown is finished, send a message to the main application to display "You FAIL".
Max.
Watched code never compiles.
|
|
|
|
|
Why bother with a secondary thread if you're going to use window messages to inform the main thread? A vanilla timer set using SetTimer[^] is quite capable of achieving the same result more efficiently.
Steve
|
|
|
|
|
|
Sir, Here is your timer hasani2007. Its in 'dirty c code', clean it up.
set the variable count_down_time_in_secs in seconds for desired count down time.
The Code is self explanatory.
1 minute = 60 secs
5 minutes = 60x5 secs
30 minutes =60x30 secs
1 hour = 60x60 secs
#include <stdio.h>
#include <time.h>
int main ()
{
unsigned int x_hours=0;
unsigned int x_minutes=0;
unsigned int x_seconds=0;
unsigned int x_milliseconds=0;
unsigned int totaltime=0,count_down_time_in_secs=0,time_left=0;
clock_t x_startTime,x_countTime;
count_down_time_in_secs=10;
x_startTime=clock();
time_left=count_down_time_in_secs-x_seconds;
while (time_left>0)
{
x_countTime=clock();
x_milliseconds=x_countTime-x_startTime;
x_seconds=(x_milliseconds/(CLOCKS_PER_SEC))-(x_minutes*60);
x_minutes=(x_milliseconds/(CLOCKS_PER_SEC))/60;
x_hours=x_minutes/60;
time_left=count_down_time_in_secs-x_seconds;
printf( "\nYou have %d seconds left ( %d ) count down timer by TopCoder
",time_left,count_down_time_in_secs);
}
printf( "\n\n\nTime's out\n\n\n");
return 0;
}
.
.
.
TopCoder
|
|
|
|
|
A busy loop is perhaps not the best way to go about things.
Steve
|
|
|
|
|
Hi Folks,
nothing like coming late to the party but as no one has mentioned the way most games are written I thought I'd stick me oar in...
In any game the timing is worked into the main dispatch loop. Every cycle around your dispatch loop you grab input, you update the timer, evolve the rest of the system based on how much time has elapsed and then render the game world according to what's happens. It looks something like this:
unsigned last_time = get_current_time_in_ms();
while( true )
{
update_IO_state();
unsigned time_now = get_current_time_in_ms();
unsigned ms_this_loop = time_now - last_time;
last_time = time_now;
evolve( ms_this_loop );
render();
}
All the functions take some additional parameters depending on how you store your game state.
The key point of this lot is that the game hammers along flat out - the thread this is on will eat a CPU. It churns out frames as often as it can and slows down when there's something system intensive happening. Oh, and if you do your IO on another thread make sure everything is synchronised properly or something weird WILL happen, possibly not on your computer but on your first customer's computer.
Hope that helps,
Cheers,
Ash
|
|
|
|
|
I am dealing with a simple program in c(win32 console).
the program should be able to print first n sentences of y=1-x+x^2/2-x^3/6+...+(-1)^n(x)^n/n!
but I can't do it because I should program with recursive function.
IS THERE A FRIEND HELP ME...
|
|
|
|
|
Try first to code recursively the factorial function (it would be a good starting point) then you if you have problems with it, ask here.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Can you code it iteratively?
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi all,
I'm doing some simple stuff to get used to MSVS. I've created a simple SDI with MS Access database support that display the keyboard pressed to the dialogue and store the keyboard pressed to the database. However, all i've got is only the beeps when I pressed the keyboard, even if I take the main portion out and just print a test.
Anyone any ideas? Here's the code anyways:
void CTest9View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
m_stest = char(nChar);
CRecordView::OnKeyDown(nChar, nRepCnt, nFlags);
}
Thanks for any help in advance
dnqhung
|
|
|
|
|
Hi,
Somewhere in your implementation file for your view class you should see a horrific looking block of macros. It'll look something like:
BEGIN_MESSAGE_MAP(CMFC_testView, CView)
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
ON_WM_KEYDOWN()
END_MESSAGE_MAP()
Has your block of macros got the line ON_WM_KEYDOWN() in it? If it hasn't then try sticking it in and seeing if the code starts magically working.
If it doesn't work then perhaps a session of delving into how MFC routes messages might be in order. Paul DiLascia wrote a decent article on it years ago for MSJ ("Meandering Through the Maze of MFC Message and Command Routing" http://www.microsoft.com/msj/0795/dilascia/dilascia.aspx[^]) about it and tells you why you need all those funky macros and why message handlers aren't virtual.
Hope that helps,
Cheers,
Ash
|
|
|
|
|
hi,
thank you for your answer, I've checked and found it in my code,
IMPLEMENT_DYNCREATE(CTest9View, CRecordView)
BEGIN_MESSAGE_MAP(CTest9View, CRecordView)
//{{AFX_MSG_MAP(CTest9View)
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()
However, it still not work. I met this problem when i studied with dialoge, and solved it with PretranslateMessage.
BOOL CTimerver2Dlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message == WM_KEYDOWN)
{
SendMessage(WM_KEYDOWN, pMsg->wParam, pMsg->lParam);
}
if (pMsg->message == WM_KEYUP)
{
SendMessage(WM_KEYUP, pMsg->wParam, pMsg->lParam);
}
return CDialog::PreTranslateMessage(pMsg);
}
I've tried it in this SDI, but nothing happen.
I'm just a newbie in VSC, any way to do it?
Thanks for your links, i'll try to learn it.
best regards,
dnqhung
dnqhung
|
|
|
|
|
Hi again,
I've never used CRecordView so I'm probably not going to be a lot of help, however if you try deriving your class from CView instead does it start working? Or rather does the handler function get called, it won't do exactly what you want as it won't be derived from CRecordView. If it does then something in CRecordView is probably eating the message.
If you're feeling masochistic you could try stepping through the MFC source code to see where the message gets sent. One thing you could try is overiding PreTranslate message and use it as somewhere to stick a breakpoint in, e.g:
BOOL "your view class name"::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
__asm int 0x03;
}
return CDialog::PreTranslateMessage(pMsg);
}
This hardcodes a breakpoint whenever a WM_KEYDOWN comes flying past PreTranslateMessage. You can then follow where the message goes and see if there's another control or window that eats the message.
Cheers,
Ash
PS: __asm int 0x03; is not the official Microsoft way of breaking into the debugger - being lazy and a recovering assembly language programmer it's the method I use. I think the official way is to call (from memory) DebugBreak();
|
|
|
|
|
Dear sir,
thank you for your help. Your answer was very useful for me. I now know where the message come to. The static text in the dialog has eaten it. However, i still need to learn hard to understand the Message in window. Sometime i don't no where it go
thank you,
best regards,
dnqhung
dnqhung
|
|
|
|
|
I call LoadLibrary in my program to call up a 3rd party DLL which in turn runs some EXE.
I want to know the version info of this external EXE in my C++ program so I can decide whether to issue a particular command to the loaded DLL. Is there a way to do this?
I think I can get the path to the EXE from the registry, and of course, I know the name of the EXE.
If I don't check the version and send the command blindly, some quite nasty and inconvenient things happen (the hardware I'm trying to control with my program goes a bit nuts). I can ask the user to check the version of all the bits and pieces of software they have installed on their PC before running my program, but human error isn't always avoidable. I need an automatic way of ensuring that certain commands are NOT issued so that the operator doesn't have to spend an hour recovering the hardware from a limbo state.
Any help greatly appreciated.
Almost, but not quite, entirely unlike... me...
modified on Tuesday, May 18, 2010 2:50 AM
|
|
|
|
|
|
Of course! Why didn't I think of that!?
Thanks, you saved me a heck of a lot of time!
Almost, but not quite, entirely unlike... me...
|
|
|
|