|
small info from msdn : LoadLibraryA -ANSI and LoadLibraryW - Unicode
ANSI controls, which work on all Win32 operating systems, allow for maximum portability between the various Win32 operating systems. Unicode controls work on only Windows NT (version 3.51 or later), but not on Windows 95 or Windows 98. If portability is your primary concern, ship ANSI controls. If your controls will run only on Windows NT, you can ship Unicode controls. You could also choose to ship both and have your application install the version most appropriate for the user's operating system.
|
|
|
|
|
LoadLibraryA and LoadLibraryW are exported by the same kernel32.dll and there will only be one copy of that in C:\Windows\System32.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thanks for the reply. But still my confusion is:
Why LoadLibraryA loads DLL from C:\Windows folder and LoadLibraryW loads DLL from C:\Windows\System32 folder?
|
|
|
|
|
I misinterpreted your question.
Sorry about that.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Because of the A und the W at the end. They are resolving the input strings in different kind. You should explicitly call them with the approbiate string variable (without cast).
ie: CStringA sa = "..."; CStringW sw = L"...";
You better use LoadLibrary() so the compilet will choose the right version
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi, I am new to malloc and how it works. I have a pointer which I use as a "variable sized" array. When I try and free the memory that was allocated by malloc I get a "free(): invalid pointer: 0x0804b008" error". Does anyone know what the cause of this is? The memory is allocated deallocated as follows.
A function called initMatrices(); is called.
void initMatrices()
{
//Initialize the valid states array
forward_model.valid_states = (char *)malloc(2*forward_model.number_of_states*sizeof(*forward_model.valid_states));
}
forward_model is the name of the structure containing the array valid_states.
Then at the end of the program the function recycleMatrices(); is called.
void recycleMatrices
{
//Return the memory that was being used by the valid states array
free(forward_model.valid_states);
}
Am I doing something wrong? From all the tutorial/help pages I have found while googling this seems to be how the memory is freed, except none of the examples make use of a struct.
Any help would be appreciated.
Thanks
dcj
|
|
|
|
|
Probably (in the code between malloc and free ) you mess up the forward_model.valid_states pointer. Using the debugger, check out the pointer value just after malloc is executed and compare it with its value just before free is executed.
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]
|
|
|
|
|
One of the possible cause of this kind of error is that memory may be corrupted or forward_model.valid_states may be NULL. Check forward_model.valid_states array variable for not NULL condition.
Hope this may helps.
|
|
|
|
|
Check if forward_model is the same copy that is used for both malloc and free.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Additionally to what others here already suggested also make sure you are not trying to free the same memory block multiple times.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I am trying to make Windows render the mouse cursor with a user-defined delay (in milliseconds). For ex., if the user-defined delay is 100ms, the mouse should be rendered 100ms after the user moved the mouse (If you are wondering what is the use-case for this, I am doing this as a part of UI/Usability study that we are doing internally).
As a system sw guy, my initial inclination was "lets put something next to mouclass drv", but wanted to check out the user mode first (since the code most prob will be picked up by another app-only developer). I tried the low-level hooks from an article here in CP...it worked fine for tracking the mouse, but I didn't know how to introduce the delay...
Any ideas? TIA.
|
|
|
|
|
The system sends the WM_SETCURSOR message to a window if the mouse is moved.
You could probably hook this message using SetWindowsHookEx(WH_CALLWNDPROC, ... and introduce the delay there.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
How about this approach:
-you run a thread which contains a queue of delayed mouse messages, the queue could contain a timestamp for each message and the thread would check the first message's timestamp and if if the time has come, it would inject it back to the system and remove it from its own queue.
-In your mouse hook you would need a way to be able to determine if the incoming message is a delayed one or not, if it is, pass it on, if it is not a delayed message then do not pass it on but put it in the other thread's queue with the right timestamp (for example: now + delay).
It's just an idea, i haven't tried this nor have an idea how it would perform.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
modified on Tuesday, June 9, 2009 6:22 AM
|
|
|
|
|
hiii
I know
VCNs(Virtual cluster number) are clusters within a particular file,
LCNs(Logical cluster number) are clusters on the volume.
Thus VCN 0 of a file may map to LCN 2394 of a volume, VCN 1 may map to LCN 104227, and so on.
So my doubt is the the LCN of a particular volume (say G: drive) will start with 0x00...?
Thanking you..
Krish+
krishnampkkm@gmail.com
|
|
|
|
|
HI
I have a large string which is basically a path.. eg. C:\programfiles\Test\Drv\wince4.0\armv4
I need to find for \Drv in above string. Drv can be DRV or Drv . I need to find for \Drv irrespective of its case.. ie., case insensitiveness.
Can I have a api or any code snippet for this.
Thanks,
Venkat
|
|
|
|
|
It depends which which type of strings you are manipulating.
For C-style strings (simple char arrays), take a look at strstr[^].
For a CString object, take a look at CString::Find[^].
For std::string, take a look at string::find[^].
|
|
|
|
|
I am using CStrings.. I tried with CString::Find.. But it is case sensitive. I want an api which can find substring irrespective of the case.
|
|
|
|
|
If you read the docs of CString (some people do this) you find the functions MakeUpper(). With that you can make both strings with big chars so you can find it.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
StrStrI[^]
However....what you're doing is looking for an element of a path. I'd be tempted to use the Path functions[^] in shlwapi to go through the path, component by component, looking for the one you want:
bool ContainsAnElement(LPCTSTR path, LPCTSTR lookFor)
{
LPCTSTR componentEnd = PathFindNextComponent(path);
while (componentEnd)
{
if (0 == StrCmpNI(path, lookFor, componentEnd-path-1)) return true;
path = componentEnd;
componentEnd = PathFindNextComponent(path);
}
return false;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
first given string input string(C:\programfiles\Test\Drv\wince4.0\armv4) and string to be identified (Drv) convert to either upper case and lower case letters. Then use string find operation to identify sting.
here is some sample
#include<cctype>;
#include<algorithm>;
#include<string>;
#include<iostream>
using namespace std;
int string_to_upper(int ch)
{
return toupper(ch);
}
int main()
{
string s = "C:\\programfiles\\Test\\Drv\\wince4.0\\armv4";
string s1 ="\\Drv";
transform(s.begin(), s.end(), s.begin(), string_to_upper);
transform(s1.begin(),s1.end(),s1.begin(),string_to_upper);
if(s.find(s1)!=string::npos)
cout<<"string found"<
|
|
|
|
|
Hi,
I have created MFC application.I have used ListControl in it.I need to use multiple selection in ListControl.I have made single selection false.But it does not work.I have added following line.
m_lcSample.ModifyStyle(LVS_SINGLESEL, 0);
But it does not work.Can anyone help me.
|
|
|
|
|
All I can do is confirm that your code is correct and works for me - one other thing, though, the documentation for LVS_SINGLESEL states By default, multiple items may be selected, so you shouldn't need to do that anyway, unless you've explicitly selected "Single Selection" for the control in the dialog editor.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for your reply.If I select muiltiple items with "ctrl" button then I can able to do multiple selection. But for ListBox this is not the case. Previously I thought I
can do multiple selection without "ctrl" button as Listbox.Can I do that?
|
|
|
|
|
Oh, I see (I think) - you want to add to the selection whenever you click on an item? Nah, can't do that with a standard list control. However, I'm sure you could use the notifications that a list control sends (LVN_ITEMCHANGING, LVN_ITMECHANGED, NM_CLICK) to implement your selection logic.
e.g. here's some code handling notifications from a list control (list_). This inverts a particular item's selection when it's clicked on, not affecting any other control's selection state. canChangeSel_ is a bool member of the dialog, and is used to tell the LVN_ITEMCHANGING handler if it can allow selection changes or not.
void CaaaDlg::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE itemActivate = (LPNMITEMACTIVATE)pNMHDR;
const int hit = list_.HitTest(LPNMITEMACTIVATE(pNMHDR)->ptAction);
if (hit != -1)
{
canChangeSel_ = true;
list_.SetItemState(hit, ~(list_.GetItemState(hit, LVIS_SELECTED)), LVIS_SELECTED);
canChangeSel_ = false;
}
}
void CaaaDlg::OnItemChangingList1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pLV = LPNMLISTVIEW(pNMHDR);
*pResult = FALSE;
if ((pLV->uChanged&LVIF_STATE) && LVIS_SELECTED==((pLV->uNewState^pLV->uOldState)&LVIS_SELECTED))
*pResult = canChangeSel_?FALSE:TRUE;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hemlat wrote: But for ListBox this is not the case.
For a listbox, you must send it a LBS_MULTIPLESEL message.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|