|
Instead of linking against the DLL version of the runtime, link the runtime statically. It will make your image larger but remove the need to includes / install the redistributables.
|
|
|
|
|
I finally worked it out. You were right about access priveleges etc. On quitting my app would try and update a data file in the app's own program folder - hence the error (unless the folder's priveleges had been manually changed, or UAC turned off). I turned off UAC within about 5 minutes off getting Vista, so didn't realise what was happening.
Doesn't this make developing software for Vista a lot more complicated? Is Windows 7 the same?
Thanks again
GC
|
|
|
|
|
hello guys...today i was reading somewhere on internet that we can have array of size 0, which actually means an array with no elements. What is the genuine use of it? Can we say that this is another bug which is not handled (just like bounds checking of arrays) in c/c++?
|
|
|
|
|
Allowing an array size of zero is a good thing. The array still exists, even if it is empty. We can pass it, process it and otherwise use it without having to write special code.
Often, database and table queries return zero rows. Since the rows returned can be viewed as an array of rows, the number of rows is the size of the array.
|
|
|
|
|
Jalapeno Bob wrote: Allowing an array size of zero is a good thing.
Here would be a possible initial form of the thing :
template <typename T>
class SimpleArray
{
T* m_pData;
int m_iLength;
public:
SimpleArray() : m_pData(NULL), m_iLength(0) {};
...
};
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.
|
|
|
|
|
yeah, so ?
Well, you need an empty array to be able to fill it.
Watched code never compiles.
|
|
|
|
|
In my old "C" days I used zero sized arrays as placeholders for dynamic sized structs. Something like this:
<code>typedef struct _VARIABLE_SIZED_STRUCT {
BYTE data[0];
} VARIABLE_SIZED_STRUCT, *PVARIABLE_SIZED_STRUCT;
PVARIABLE_SIZED_STRUCT pDynamic = (PVARIABLE_SIZED_STRUCT)malloc(FIELD_OFFSET(VARIABLE_SIZED_STRUCT,data[iSize]));
The zero sized placeholder is antiquated and no longer needed with the C++ language. In fact I believe support for zero sized array was removed from recent MSVC compilers.
Best Wishes,
-David Delaune
|
|
|
|
|
Visual Studio 2010 will flag an error for int i[0];
You can however create it dynamically - int* i = new i[0];
|
|
|
|
|
As Superman already wrote, declaring an array with zero size is not allowed, at least on Microsoft Visual C++.
Something interesting is that, on versions prior to Visual Studio 2010, which is the first one that implements static_assert , such functionality was realized using the _STATIC_ASSERT Macro[^].
That macro tests at compile time for the given condition and give the Compiler Error C2466[^] if not satisfied. Ops! C2466 means cannot allocate an array of constant size 0.
By going deeper, we can search the macro on the crtdbg.h header:
#define _STATIC_ASSERT(expr) typedef char __static_assert_t[ (expr) ]
Now, let's try to imagine how it works...
|
|
|
|
|
You can in C99 (I think VC++ supports this syntax in structures if you use /Ze but it's not a full C99 flexible array thing) but you can't in C90 or C++. The sort of thing it's useful for in C99 is for arrays with variable sized structures. You can write:
struct foo
{
int number_of_elements_;
int elements_[];
};
and then have the constructor sort out sizing the array. In C90 and C++ you'd have to have one element and manually size everything.
Cheers,
Ash
|
|
|
|
|
Hello everyone.
I am doing a sync program that has a spying function.
The spying function will detect any changes in the Source folder and will sync it with the Destination folder as soon as detects any changes.
My problem is, when a new file is added into the Source folder, the sync function immediately will start copying the new file to the Destination folder. And, if the file is still being used by explorer for writing, the program gives an error. As the file has not been fully written.
How can I make the sync function wait for the explorer, until it finishes copying the file?
modified on Thursday, November 25, 2010 8:01 PM
|
|
|
|
|
I know the problem, and there isn't a perfect solution AFAIK. What I tend to do, whenever possible, is having the producer produce another very small file once the actual files have been handled, and use that as a signal. This of course only works when I have some say it what the producer does. When I don't, the only thing I have is polling (a wait-and-try loop).
|
|
|
|
|
mints555 wrote: And, if the file is still being used by explorer for writing, the program gives an error.
I would recommend that you attempt to open the file with exclusive access when copying. The OS should deny your request if the handle is being referenced by another process.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks for the advice David.
I solved the problem by the code shown below:
CFile sour;
CString source=_T("Path to file");
while (!sour.Open(source,CFile::modeRead | CFile::shareDenyNone,NULL))
{
Sleep(1000);
}
sour.Close();
modified on Thursday, November 25, 2010 3:34 AM
|
|
|
|
|
How could I find out where a runaway process is looping? I can attach to the process using the VS debugger but not clear where to go from there. (Also, I tried to get a dump at that point but got a permanent hourglass and had to kill the VS session.) Or is there a way at some higher level to kill the process and cause it to take a crash dump that could later be analyzed?
|
|
|
|
|
Alan Kurlansky wrote: How could I find out where a runaway process is looping?
Interesting choice of words. It contains the WinDbg command that could help your situation.
If you attach the WinDbg debugger you can issue the !runaway command which will show you the thread times. Any thread in an infinite loop will probably consume the most cpu time.
You may also want to try "!locks" and "!analyze -v -hang" in case its not an infinite loop and actually a deadlock caused by synchronization objects.
Off Topic: I really wish the VS team would add a commandline interface into the VS debugger.
Best Wishes,
-David Delaune
|
|
|
|
|
Hello Friends
I m using two ListBox in a dialog.I want to know that how can i get notification If i select member of Second List Box and to unselect the first listbox.
Thanks & Regards
Yogesh
|
|
|
|
|
Can't you just handle the ON_LBN_SELCHANGE notification?
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]
|
|
|
|
|
Hello,Thanks for the reply.
I am using ON_LBN_SELCHANGE. but with that i am using LButtonDown where do i need to know which listbox is selected.And whenever i change selection from one listbox to another.then first LButtonDown is called.And I think ON_LBN_SELCHANGE is the notification If i change the selection of strings in One Listbox.
I want to know when I click on other listbox and I want to deselect all the strings of first listbox.
Regards
Yogesh
|
|
|
|
|
Maybe I din't get you, but the notification should be mapped to two different handlers, one for each listbox (each handler handles -pardon the pun- just the 'selection change' coming from its listbox).
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]
|
|
|
|
|
Thx,I used ON_LBN_SETFOCUS to get focus of one listbox.but now i want the handle of those listbox on lBUttonDown.
I used
CWnd* pWndMlb = GetDlgItem(IDC_LISTBOX);
CWnd* pWndLlb = GetDlgItem(IDC_LISTBOX_TEMP);
bur both re coming NULL.
Regards
Yogesh
|
|
|
|
|
Are you sure IDC_LISTBOX , IDC_LISTBOX_TEMP are child controls of the window from where you're invoking GetDlgItem ?
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]
|
|
|
|
|
|
Could you post the relevant code, please?
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]
modified on Wednesday, November 24, 2010 8:24 AM
|
|
|
|
|
Hello Sir
I got the HAndle of tht ListBox in Lbutton Down.
Thanks for ur precious time .
Regards
Yogesh
|
|
|
|