|
programmer81 wrote: ...it is quite obvious that u...
No, not me.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Why you dont use of URLDownloadToFile Function.
|
|
|
|
|
Hi
I have to retrieve the registery value through RegQueryValueEx().Before
doing this I am using RegOpenKeyEx() to open the registery.But the return value of RegOpenKeyEx() I am getting is 998 i.e the function is not able to successfully open the windows registery.Although,I have tried to map the error code of getlasterror() with the help of FormatMessage(),the return value of
getlasterror() is 0 i.e. "operation completed successfully".
Here is the code:
PHKEY m_htKey;
const char* lpSubKey = "SOFTWARE\\MyProduct\\N K software\\1.5";
long* lpcbValue = NULL;
DWORD valueType = 0;
DWORD dwBufLen = 0;
const char* valueName = "NKSDir";
long res = RegOpenKeyEx(HKEY_CURRENT_USER ,lpSubKey,0,KEY_ALL_ACCESS,m_htKey);
DWORD dw = GetLastError();
LPVOID lpMsgBuf;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS, NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,0,NULL);
//Display the string.
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
if (res != ERROR_SUCCESS)
return TRUE;
else
{
printf("hi");
res = RegQueryValueEx((HKEY)m_htKey,valueName,NULL,&valueType,NULL,&dwBufLen);
}
Now in the above code, the if condition is getting true and it's returning true.The control is not going into the else condition.
Can you please suggest me what could be the reason behind it that RegOpenKeyEx() is returning non zero value?
With Regards
Neeraj Sinha
|
|
|
|
|
I don't know the solution to your problem (I never worked with the registry) but shouldn't you pass the return value of RegOpenKeyEx to your FormatMessage function instead of GetLastError ? Even if you get an error in RegOpenKeyEx, GetLastError will still return 0.
|
|
|
|
|
Yes I agree.Thanks for your help to remove my confusion.Now I am
getting the correct message of error code 998 through FormatMessage, i.e."Invalid access to memory location".
Can anybody please solve this problem?What could be the possible
reason behind this message?
With Regards
Neeraj Sinha
|
|
|
|
|
Hi,
Cedric's comment is correct, you need to pass the value returned from RegQueryValueEx() to FormatMessage() and then tell us the error you are getting before we can help.
|
|
|
|
|
LONG regResult = ERROR_SUCCESS;
HKEY hKey;
regResult=RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"Software\\MyProduct\\N K software\\1.5"
,0,KEY_ALL_ACCESS,&hKey);
if(regResult == ERROR_SUCCESS)
{
unsigned long type=REG_SZ, size=1024;
char res[1024]="";
char res2[1024]="";
long err=RegQueryValueEx(hKey,"Reference",NULL,&type,(LPBYTE)&res[0],&size);
RegCloseKey(hKey);
if(err==ERROR_SUCCESS)
{
//....do necessary code here }
else
//...do code here
}
Hope this will help you!!!!!!!!!!1
|
|
|
|
|
Hi Cedric,Jonathan and D.Mani
Thanks a lot for your quick replies.
I got my problem completely solved now.
With Regards
Neeraj Sinha
|
|
|
|
|
|
My project has a dialog, in this dialog, have two control: A and B
when this dialog print, A covered B, but when B has some change(change color, for example), and then B covered A.
How to lead A covered B again? Thanks!
|
|
|
|
|
Look up SetWindowPos(),you should be able to use this to change your controls Z-order.
|
|
|
|
|
if that's normal for your design that they overlap, then you should hide the control overlapped by calling ShowWindow(FALSE) on it.
otherwise, you have a design issue in your dialog :p
|
|
|
|
|
I set a Dialog's "Vertical scroll" property true.Now I want to calculate its scroll bar's width. how to do it ?
Thanks in advance.
|
|
|
|
|
Peter, Chan wrote: I set a Dialog's "Vertical scroll" property true.Now I want to calculate its scroll bar's width. how to do it ?
::GetSystemMetrics( SM_CXVSCROLL );
|
|
|
|
|
|
|
Hi all,
I was wodering if it is possible to pass values to a thread function without calling _beginthread() for a second time. For example, a thread is created and the thread performs it's tasks, now the thread must perform the same task but this other data, and one doesn't want to create a new thread again. Is this possible ???
Many Thanks
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
Yes: there are several ways to do that. In general, what I do is a thread that simply calls a member function of a class to do some processing. The class is passed as an argument to the thread function.
So, as the function is a member of the class, you have access to all the members of the class and you can modify them. Of course, you need to secure this with synchronization objects (critical sections, mutexes, ...) to avoid that a same 'member' is accessed at the same time by two different threads.
I hope it makes sense.
|
|
|
|
|
Thanks Cedric, yes it makes sense, kinda. If I may be so bold as to ask for an example if it is possible.
Many Thanks
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: If I may be so bold as to ask for an example if it is possible.
Something like this:
class CThread
{
public:
CThread();
virtual ~CThread();
void StartThread();
void ThreadFunc();
HANDLE m_hThread;
};
DWORD WINAPI ThreadProc(LPVOID lpParam)
{
CThread* pThread = (CThread*)lpParam;
if (pThread)
pThread->ThreadFunc();
return 0;
}
CThread::CThread()
{
}
CThread::~CThread()
{
}
void CThread::StartThread()
{
m_hThread = CreateThread(NULL,0,ThreadProc,this,0,NULL);
}
void CThread::ThreadFunc()
{
}
|
|
|
|
|
|
Hi,
I have a web based application in which we have 8 ocx for displaying images.
Currently images are loaded from CD .But now we want to allocate some memory in some of the 8 ocx we have and in this memory we will save maximum files that we could.
Then we want to access this memory buffer using cmemfile.
So we need to create a common memory which can be accessed by all the ocx on the page.
I dont know how to create such memory? And then how to access the memory through different ocx.
Please provide me some inputs on this..
Surendra Vishwkarma
|
|
|
|
|
You might want to look up the CoTaskMemAlloc function and also Memory Mapped Files. Your biggest problem is likely to be browser security. It will not like your embedded controls accessing memory outside their normal scope. You might even have to consider replacing the OCX with Javascript but hopefully not .
It should be possible to write script on the page which can access the controls and negotiate between them which one will own/create a memory mapped file and then communicate it's handle to the other controls.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hi,
I have a Win32 Console Application which is throwing the Debug Assertion Failed! .. _CrtIsValidHeapPointer( pUserData ) and followed by a Debug Assertion Failed! .. _BLOCK_TYPE_IS_VALID(pHead->nBlockUse).
After I did a Step by Step Debug strangely what I saw was it is throwing error once it is exittin the main function.
Unlike any character pointers and deletion of heap without its references as of when generally this error occurs I have no such instances.
please could you suggest a probable solution to this. please help.
There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing.
Oscar Wilde (1854-1900)
Regards...
Shouvik
|
|
|
|
|
Looks like you are trying to delete the same pointer twice, or trying to delete something which is not a pointer to a heap based object.
If you can post some of the code, then we can help.
|
|
|
|