|
The error is that if I put
HANDLE hfile=CreateFile("c:\\Myapp\\Myfile.txt",......) WORKS (the handle is not -1) And if I put the code of my first post with the same name file when debugging the return value is -1 and the problem is related to the name of the file.
Why is diferent "c:\\Myapp\\Myfile.txt" to "c:\Myapp\Myfile.txt" that is what I receive from the get app path?
Thanks for your help.
Best Regards
Doc
|
|
|
|
|
So Sorry guys
Completely my fault. Unfortunately the file was open before, and the error was due to this.
Sorry for your time spent in this silly mistake.
Get a beer , I'll pay.
Doc
|
|
|
|
|
I've got a problem and I was wondering if anyone else has had it, and if so, how they fixed it.
I've created an installer package using Visual Studio, and it works just fine about 99% of the time. However, a few times when it goes to install the program (on an upgrade), it won't really upgrade the program to the new executable and create another entry in the add/remove programs window. I have the DetectNewerInstalledVersion set to true, along with Remove PreviousVersions, and have incremented the Version.
It does install/upgrade correctly most of the time, but on two computers so far, the user has to manaully uninstall the previous version before it will install correctly. Any ideas on what is going on/how to fix it?
|
|
|
|
|
Well not really a programming question. What, if any, kind of software protection scheme do you or you company use to protect yourself against piracy, ect?
Any recommendations for commercial products?
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
Well, it depends on your wish. It's quite possible to make everything yourself, with key around 30 chars, code encryption etc. I did this in my last project, since I don't wanted to use Asprotect, and it seems to be quite stable till now.
There are also several ready to use solutions:
-Asprotect (aspack.com, at the moment they have some problems, either with hosting or hackers): long key (around 500 characters), but version 2 promised to have short key;
- Armadillo (http://www.siliconrealms.com/armadillo.shtml)
- HardKey(http://www.strongbit.com/) - short key;
- activatesoft.net - activation service, combined with hardkey system;
You can also check http://www.exetools.com/protectors.htm for a list.
Anyway, do not forget that anything can be cracked. What can not be cracked in pure, will be purchased, cracked, and chargebacked
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
Thanks for your suggestions. I will check them out. Sometimes the boss had a good idea. He would rather us spend our time working on the core program than the "fluff". So he would rather just buy a solution off the shelf rather than waste our time trying to come up with a scheme. He is very time-to-market oriented.
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
I want to do stuff like :
dc2->MoveTo(f,w);
dc2->LineTo( f + 20, w);
but not in the OnDraw() function which makes the line show up from the very start.
When a button is pressed I want to draw the line. If I put in the button click function:
CDC dc2;
dc2->MoveTo(f,w);
dc2->LineTo( f + 20, w);
of course it crashes. So how does one do this?
thanks
ns
|
|
|
|
|
|
call Invalidate() or InvalidateRect
|
|
|
|
|
The problem ns has is that dc2 has not been assigned to a device context.
You are right however that after drawing you need to invalidate.
Ant.
|
|
|
|
|
You can get the DC at anytime by calling GetDC(). But unless you want the line to be overdrawn the next time the OnDraw() is called then you should just set a flag when the button is pushed and invalidate the area being drawn to.
if( bFlag )
INTP
|
|
|
|
|
The right way to do this is to maintain a data structure that contains a collection of linked points. The data structure is updated in your button's handler. Your view's OnDraw() handler should paint itself (i.e. draw lines) based on the points in the data structure.
See the MFC "Scribble" demo app to see how this is done.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Appreciate the help. Many thanks,
ns
|
|
|
|
|
I've been playing with a CString implementation I found here (Thanks, Joe!)[^] and it collides with another header I use. Compiling my app produces the following warning:
Warning C4065: switch statement contains 'default' but no 'case' labels and points to this section (and another like it) in Joe's StdString.h header:
inline void ssasn(std::wstring& sDst, const int nNull)<br />
{<br />
UNUSED(nNull);<br />
ASSERT(nNull==0);<br />
sDst.assign(L"");<br />
}
I've found UNUSED defined in several ways, in a lot of headers. Here's how it looks in ...\VC98\MFC\Include\AFX.h:
#ifdef _DEBUG<br />
#define UNUSED(x)<br />
#else<br />
#define UNUSED(x) x<br />
#endif<br />
#define UNUSED_ALWAYS(x) x
but in a third-party header I need, it gets defined thus:
#ifndef UNUSED<br />
#ifdef _CVI_<br />
#define UNUSED(a)<br />
#else<br />
#define UNUSED(a) switch((int)&a){default:break;} /* bypass bogus warnings on external compilers */<br />
#endif
It's this last definition that seems to be getting used in the compilation and generates the warning.
Any ideas what this is for? Can I remove the offending references to it without some weird side effect?
Thanks in advance for all your help.
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
It's actually in place to squelch another compiler warning: C4101. A variable was declared, but never used. You can add a #pragma warning(disable:4507) statement if you don't like the C4065 warning.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks, David!
I think you meant disable:4065, but that was enough to overcome my issue.
BTW, why is this sprinkled all over Microsoft's code? Shouldn't one simply remove the reference to the unused variable?
Long Live CodeProject!
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
> Shouldn't one simply remove the
> reference to the unused variable?
It depends. Consider this:
void myfunc1(LPVOID p)<br />
{<br />
ASSERT(p);<br />
}<br />
It's a bit non-natural, but it give you an idea - item can be used in one configuration, but unused in another.
Or maybe this one is better:
void myfunc2(LPVOID p)<br />
{<br />
#ifdef _UNICODE<br />
#else<br />
UNUSED_ALWAYS(p);<br />
#endif<br />
}
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
Jesse Evans wrote:
I think you meant disable:4065, but that was enough to overcome my issue.
You're right. How I got C4507 is anyone's guess.
Jesse Evans wrote:
BTW, why is this sprinkled all over Microsoft's code? Shouldn't one simply remove the reference to the unused variable?
I'm not sure. Have a look at the USES_CONVERSION preprocessor directive. It will declare a variable and then use that variable all by itself in a statement just to keep the compiler from complaining about an unreferenced variable.
There's also the case of unreferenced function parameters. With C++, you can declare a function and omit the names of any unused parameters. With C that was not possible, so inside of the function, you could use the UNUSED() macro to get ride of the C4101 warning. Make sense?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks, Igor and David. Makes sense, now.
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Hi all,
I need to monitor the NT/2000/XP network environment for files that I have created and files that I have renamed.
I based my program on the FWATCH example of MSDN, i.e., I'm using ReadDirectoryChangesW and IO Completion Port to receive the notification.
The problem is that I also get notified when some other user (not me) creates or renames a file on the directory that I am monitoring.
Is there any way to filter the notifications so that I only get notified when I create or rename files? If not, is there any way to know which user caused the notification?
Thanks.
|
|
|
|
|
LKogut wrote:
Is there any way to filter the notifications so that I only get notified when I create or rename files? If not, is there any way to know which user caused the notification?
When a file is created, you can use GetNamedSecurityInfo() and LookupAccountSid() to see if the current owner of the file is you. Also, if renaming a file causes the owner to change, this will work too.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks David, this will help me for sure!
But, unfortunately, not 100%. Looking for the functions on the help, they only work on an NTFS file system. Any clue for non NTFS file system?
|
|
|
|
|
How do I resize my PropertySheet and all pages based on size of the Main Dialog ?
I derived a class from PropertySheet and tried to implement an OnInitDialog .
Here's what i tried but didnt come out good
BOOL CMainSheet::OnInitDialog() {<br />
CPropertySheet::OnInitDialog();<br />
CWnd *parentWnd = this->GetOwner();<br />
ASSERT(parentWnd);<br />
parentWnd->GetClientRect(&parentRect);<br />
CTabCtrl *pTab = GetTabControl();<br />
ASSERT(pTab);<br />
this->SetWindowPos(0,parentRect.left,parentRect.top,200,200,0);<br />
pTab->SetWindowPos(0,parentRect.left,parentRect.top,200,30,0);<br />
<br />
<br />
CPropertyPage *page = GetActivePage();<br />
ASSERT(page);<br />
this->GetClientRect(&r);<br />
page->SetWindowPos(0,r.left,r.top,180,180,0)<br />
return TRUE ;<br />
}
Please advise
|
|
|
|
|
Is there any way to create a CArray object on the heap rather than on the stack?
Thanks
|
|
|
|
|
Yes, but why would you want to? As you add items to the array, memory is allocated from the heap to hold the individual items. The array object itself consumes very little memory.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|