|
I use this code to create a value in Registry:
CString strValue;
DWORD dwBytes ;
LPBYTE lpData ;
strValue=_T("1doandaithietladaidaihoncaidoanhoinaylunnecoithumaychaydcko?");
dwBytes = strValue.GetLength()+1;
lpData = (LPBYTE) strValue.GetBuffer(dwBytes);
::RegSetValueEx(m_hSectionKey, _T("Test"), NULL, REG_SZ, lpData, dwBytes);
But the value data in Registry is just : "1doandaithietladaidaihoncaidoa"
Someone plz help me to explain & give me a solution
|
|
|
|
|
Your building a UNICODE application hence each character is 2 bytes wide.
The correct value for dwBytes is:
dwBytes = (strValue.getLength()+1)*sizeof(TCHAR);
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
|
|
|
|
|
And see this[^] article for more help.
|
|
|
|
|
Oh It worked, thanks so much
|
|
|
|
|
Why are you calling GetBuffer() ? Unless you are also modifying strValue , it is unnecessary and potentially dangerous.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Good point.
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
|
|
|
|
|
Hi,
I and writing MFC application for Mobile 6 on HP iPAQ.
When I tap on the screen (with stylus) and continue to hold it (TAP and HOLD), a circle of "small solid circles" appear. I do not want to implement any context menu; instead I want this circle of "small solid circles" to disappear.
I am thinking that if I can somehow catch an even for "TAP and HOLD" I can avoid this.
If you could let me know how to do this I would greatly appreciate it.
Thanks!
-A
|
|
|
|
|
|
I am tring to write a class that defines location based on latitude & longitude. I have searched high and low with no such luck. Can anyone help?
|
|
|
|
|
|
Here is what I have so far. I'm now tring to figure out how to get both Latitude & Longitude to appear. Not just one or the other. I also need to get North/South East/West into the code. Any ideas?
<br />
<br />
class location<br />
{<br />
private:<br />
int degrees;<br />
int minutes;<br />
int seconds;<br />
<br />
public:<br />
location(int d, int m, int s);<br />
~location();<br />
<br />
void setdegrees(int d);<br />
void setminutes(int m);<br />
void setseconds(int s);<br />
<br />
<br />
int getdegrees();<br />
int getminutes();<br />
int getseconds();<br />
void properties();<br />
};<br />
<br />
<br />
#include<iostream><br />
#include"location.h"<br />
<br />
using namespace std;<br />
<br />
location::location(int d, int m, int s)<br />
{<br />
degrees = d;<br />
minutes = m;<br />
seconds = s;<br />
}<br />
<br />
location::~location()<br />
{<br />
<br />
}<br />
<br />
void location::setdegrees(int d)<br />
{<br />
degrees = d;<br />
}<br />
<br />
void location::setminutes(int m)<br />
{<br />
minutes = m;<br />
}<br />
<br />
void location::setseconds(int s)<br />
{<br />
seconds = s;<br />
}<br />
<br />
int location::getdegrees()<br />
{<br />
return degrees;<br />
}<br />
<br />
int location::getminutes()<br />
{<br />
return minutes;<br />
}<br />
<br />
int location::getseconds()<br />
{<br />
return seconds;<br />
}<br />
<br />
void location::properties()<br />
{<br />
cout<<" Degrees"<<getdegrees() <<endl;<br />
cout<<" Minutes"<<getminutes() <<endl;<br />
cout<<" Seconds"<<getseconds() <<endl;<br />
}<br />
<br />
<br />
#include"location.h"<br />
#include<iostream><br />
<br />
int main(int argc, char *argv[])<br />
{<br />
location city(51, 30, 0);<br />
city.properties();<br />
<br />
system("PAUSE");<br />
return 0;<br />
}<br />
|
|
|
|
|
so why wouldnt you have something like :-
//location.h
class location
{
private:
(some appropriate data type) longitude;
(some appropriate data type) latitude;
its not impossible to continue with what you've got though if thats what you really want - then you could do
//location.h
class location
{
private:
int lat_degrees;
int lat_minutes;
int lat_seconds;
int long_degrees;
int long_minutes;
int long_seconds;
but that means now you've got 3 set/get routines for 'lat' d/m/s and 3 for 'long'
.. Im sure somewhere in those links I gave you was a better way of storing lat/longs than d/m/s, but I didnt read them fully, they were for ideas ....
'g'
|
|
|
|
|
i have a problem creating resourcebundle....i made two programs
1.resourcecreator.exe( it creates the resource using calc.exe into extractor.exe)
2.extractor.exe ( it is the program on which resource is created....and same program when run uses itself to extract the resource calc.exe)...
on creating resource by using resourcecreator.exe when i try to run updated extractor.exe it gives error..."extractor.exe is not a valid win32 application"...
resourcecreator.cpp
#include"windows.h"
#include"conio.h"
#include"stdio.h"
int main()
{
HANDLE hFile;
HANDLE hResource;
DWORD dwFileSize,
dwBytesRead;
LPBYTE lpBuffer;
hFile = CreateFile("calc.exe", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile == NULL )
{
printf("%s","file not opened" );
}
else
{
printf( "%s","file opened" );
}
if (INVALID_HANDLE_VALUE != hFile)
{
dwFileSize = GetFileSize(hFile, NULL);
lpBuffer = new BYTE[dwFileSize];
if (ReadFile(hFile, lpBuffer, dwFileSize, &dwBytesRead, NULL) != FALSE)
{
hResource = BeginUpdateResource("extractor.exe", FALSE);
if (NULL != hResource)
{
if (UpdateResource(hResource,
RT_RCDATA,
MAKEINTRESOURCE(104),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPVOID) lpBuffer,
dwFileSize) != FALSE)
{
EndUpdateResource(hResource, FALSE);
printf("%s","\nresource updated" );
}
}
}
delete [] lpBuffer;
CloseHandle(hFile);
}
getch();
return 0;
}
-----------------------------------------------
extractor.cpp
#include"windows.h"
int main()
{
HMODULE hLibrary;
HRSRC hResource;
HGLOBAL hResourceLoaded;
LPBYTE lpBuffer;
hLibrary = LoadLibrary("extractor.exe");
if (NULL != hLibrary)
{
hResource = FindResource(hLibrary, MAKEINTRESOURCE(104), RT_RCDATA);
if (NULL != hResource)
{
hResourceLoaded = LoadResource(hLibrary, hResource);
if (NULL != hResourceLoaded)
{
lpBuffer = (LPBYTE) LockResource(hResourceLoaded);
if (NULL != lpBuffer)
{
DWORD dwFileSize,dwBytesWritten;
HANDLE hFile;
dwFileSize = SizeofResource(hLibrary, hResource);
hFile = CreateFile("newcreation.exe", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE != hFile)
{
WriteFile(hFile, lpBuffer, dwFileSize, &dwBytesWritten, NULL);
CloseHandle(hFile);
}
}
}
}
FreeLibrary(hLibrary);
}
return 0;
}
can you guide me a little bit...it would be really nice..
thanx....mail me at ashutosh.dhiman@gmail.com
there are 10 type of people in the world...
01 who understand binary.
10 who don't...
|
|
|
|
|
hey every one...i have a prob.....i am making a program which will generate an exe...i want when i run my program....it should make a text file which is not a problem and one exe file...which is some other program that i built......not the same as the program from which im making this exe....what should i do for that??? i just had a random idea in my mind...i though every file is a file...why not try like text file..so i changed the extension of the exe(that i want to generate by running other one i.e. exe that i want to produce) in txt...then copied that into fputs("all the converted file contents here", outfile)....then tried to run...changed all escape seqence and all( like " changed to \" )...but didn't work as i expected....i knw its a very lame idea.... ...can someone tell me how to do this....any idea guys??/
there are 10 type of people in the world...
01 who understand binary.
10 who don't...
|
|
|
|
|
I don't understand you binary.
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
|
|
|
|
|
|
ROTFL, particularly when OP replied. I guess you were asking about the question.
modified on Friday, May 9, 2008 11:35 AM
|
|
|
|
|
Indeed.
I suppose he/she is very young.
[added]Rajkumar R wrote: I guess you were asking about the question.
Of course you guessed well (maybe our binaries match better).
[/added]
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
|
|
|
|
|
actually im making a keylogger using windows keyboard hook....keylogger is working very well....it has two files one is executable and other is dll file....what i want is to make an executable file which when run generates these two files and copies it somewhere let say windows directory....and makes an entry in registry to load at startup...now making registry is not a problem...problem is how do i make a single exe file which generates these two files( dll and keylogger.exe).....a guy in this post told me to include that exe in my project which will be extracted when i run that project....don't knw how to do that...thats my question...help?????
there are 10 type of people in the world...
01 who understand binary.
10 who don't...
|
|
|
|
|
At least this is my personal point of view.
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
|
|
|
|
|
i got help for keylogger from your website only....
there are 10 type of people in the world...
01 who understand binary.
10 who don't...
|
|
|
|
|
CPallini wrote: I suppose he/she is very young.
How can you understand s(he) is young? it was other secrect that you found it.
|
|
|
|
|
It's my fully powered CPMRU , you know.
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
modified on Friday, May 9, 2008 3:19 PM
|
|
|
|
|
But what is CPMRU?
|
|
|
|
|
C ode P roject M ind R eader U nit (first appeared in a David Crow reply, if I recall well).
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
|
|
|
|