|
Bob Stanneveld wrote:
why you define _tmain() in a MFC application?
It's a console MFC app (specifically, a test framework for a lib that happens to link with MFC).
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
-- modified at 23:57 Monday 5th September, 2005
|
|
|
|
|
Hi,
I use webbrowser control in a vc project,and when navigate to a local file which contains ActiveXObject .Then it blocks .
How can i let the webbrowser direct shows the contenct without user allows it.
A example of it is the Directx Sample Browser .I want just the same .
Some one please help me. Thanks
|
|
|
|
|
I seem to have a compatibility issue with functions accessing the registry. All XP systems work well but 98 and 2K seem to decide they won't play. Its common to all Reg...Ex() functions. Anyone know how to solve this cross Windows issue before I start coding everything in 16bit.
Many thanks
<br />
bool WriteKey(char * key_type, char * key)<br />
{<br />
bool status = true;
<br />
LONG ret;<br />
<br />
HKEY kh1, kh2;<br />
<br />
DWORD disposition;<br />
<br />
char *buf1;<br />
char *buf2;<br />
<br />
buf1 = new char[256];<br />
buf2 = new char[256];<br />
<br />
<br />
ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, <br />
"SOFTWARE\\KEY1", <br />
0,<br />
NULL,<br />
REG_OPTION_NON_VOLATILE,<br />
KEY_ALL_ACCESS,<br />
NULL,<br />
&kh1,<br />
&disposition);<br />
<br />
ret = RegCreateKeyEx(kh1, <br />
"KEY2",<br />
0,<br />
NULL,<br />
REG_OPTION_NON_VOLATILE,<br />
KEY_ALL_ACCESS,<br />
NULL,<br />
&kh2,<br />
&disposition);<br />
<br />
<br />
if(ret != ERROR_SUCCESS)<br />
{<br />
MsgBox("WriteKey(): RegCreateKeyEx: Failed.");<br />
status = false;<br />
}<br />
<br />
ret = RegSetValueEx(kh2, key_type, 0, REG_SZ, (CONST BYTE *) key, strlen(key) + 1);<br />
<br />
if(ret != ERROR_SUCCESS)<br />
{<br />
MsgBox("WriteKey(): RegSetValueEx: Failed.");<br />
status = false;<br />
}<br />
<br />
ret = RegCloseKey(kh1);<br />
ret = RegCloseKey(kh2);<br />
<br />
if(ret != ERROR_SUCCESS)<br />
{<br />
MsgBox("WriteKey(): RegCloseKey: Failed.");<br />
status = false;<br />
}<br />
<br />
delete buf1;<br />
delete buf2;<br />
<br />
return status;<br />
}<br />
u6ik
|
|
|
|
|
Cracked it. Simple really...
<br />
<br />
ret = RegSetValueEx(kh2, key_type, 0, REG_SZ, (CONST BYTE *) key, strlen(key) + 1);<br />
<br />
if(ret != ERROR_SUCCESS)<br />
{<br />
ret = RegSetValue(kh2, key_type, (CONST BYTE *) key, strlen(key) + 1);<br />
}<br />
Just use the older code if the newer code fails. Bit of a faf, but it works.
u6ik
|
|
|
|
|
Hello.,
I developed an application which stores some data.
Next I create a setup file .
The SetUp file (If I installed in my Machine) works fine in my System, But It can not works fine in other machines.
=>Because I hard coded the DSN name as 'MyDSNName'
and Database Table as 'MyDataBase'
--
I wrote code like this.-=-->
-------------
CString sql,sDate;
CString sDriver = "MICROSOFT ACCESS DRIVER (*.mdb)";
CString sDsn;
CString sFile = "c:\\mydatabase.mdb";
CDatabase db;
sDsn.Format("ODBC;DRIVER={%s};DSN='MyDsnName';DBQ=%s",sDriver,sFile);
db.Open(NULL,false,false,sDsn);
CRecordset recset( &db);
------------
>>I want flexible code ,which works fine for all machines.,
Praveen Chowdam Kumar
|
|
|
|
|
parims wrote:
sDsn.Format("ODBC;DRIVER={%s};DSN='MyDsnName';DBQ=%s",sDriver,sFile);
You are using a DSN name that maybe it's not created in the others computers. This article[^]may help you.
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
Hi,
How can one the setupapi device driver removing?
What do I make wrong in my code?
Can anybody help me at the problem?
Thanks
Peter
<br />
#include "stdafx.h"<br />
#include <stdio.h><br />
#include <windows.h><br />
#include <setupapi.h><br />
#include "cfgmgr32.h"<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
<br />
PSP_DEVICE_INTERFACE_DETAIL_DATA pspdidd;<br />
SP_DEVICE_INTERFACE_DATA spdid;<br />
SP_DEVINFO_DATA spdd;<br />
HDEVINFO hDevInfo;<br />
DWORD dwIndex, dwSize, dwType;<br />
TCHAR szProperty[256];<br />
GUID ClassGUID;<br />
TCHAR ClassName[MAX_CLASS_NAME_LEN];<br />
LPTSTR INFFile = argv[1];<br />
CString strInfClassID;<br />
BOOL isInstall = FALSE;<br />
<br />
ZeroMemory(&spdid, sizeof(spdid));<br />
spdid.cbSize = sizeof(spdid);<br />
<br />
if(!SetupDiGetINFClass(INFFile,&ClassGUID,ClassName,sizeof(ClassName),0))<br />
{<br />
printf("GetINFClass");<br />
goto cleanup_DeviceInfo;<br />
}<br />
<br />
LPOLESTR InfBuffer;<br />
<br />
StringFromCLSID( ClassGUID, &InfBuffer );<br />
strInfClassID = InfBuffer;<br />
CoTaskMemFree(InfBuffer);<br />
<br />
<br />
hDevInfo = SetupDiGetClassDevs(&ClassGUID, NULL, NULL,<br />
DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);<br />
<br />
<br />
<br />
<br />
<br />
if(hDevInfo == INVALID_HANDLE_VALUE)<br />
{<br />
printf("SetupDiGetClassDevs nicht gefunden.\n ");<br />
goto cleanup_DeviceInfo;<br />
<br />
}<br />
<br />
<br />
<br />
for(dwIndex = 0; (SetupDiEnumDeviceInterfaces(hDevInfo,NULL, &ClassGUID, dwIndex,&spdid)); dwIndex++)<br />
{<br />
<br />
SP_REMOVEDEVICE_PARAMS rmdParams;<br />
<br />
rmdParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);<br />
rmdParams.ClassInstallHeader.InstallFunction = DIF_REMOVE;<br />
rmdParams.Scope = DI_REMOVEDEVICE_GLOBAL;<br />
rmdParams.HwProfile = 0;<br />
<br />
if(!SetupDiSetClassInstallParams(hDevInfo,NULL,&rmdParams.ClassInstallHeader,sizeof(rmdParams)) ||<br />
!SetupDiCallClassInstaller(DIF_REMOVE,hDevInfo,NULL)) <br />
{<br />
printf("Driver not remove.");<br />
}<br />
else<br />
{<br />
printf("Driver remove.");<br />
<br />
}<br />
<br />
<br />
}<br />
<br />
cleanup_DeviceInfo:<br />
<br />
SetupDiDestroyDeviceInfoList(hDevInfo);<br />
<br />
return 0;<br />
}<br />
<br />
<br />
|
|
|
|
|
I have got a handle of a Window and now I want to change color of that window. How do I set new Color for that Window at run-time ?
|
|
|
|
|
|
|
TCHAR* buffer = new TCHAR[1024];
UINT ret = pFile->Read(buffer, 1024);
while ( ret != 0 )
{
buffer[ret] = TEXT('\0');
strText = buffer;
OutWebResource += strText;
ret = pFile->Read(buffer, 1024);
}
pFile->Close();
|
|
|
|
|
I used this read UNICODE data, but It seemed that there is always mem uninitialized. what's the matter?
|
|
|
|
|
I don`t understand what u really want but after declaring TCHAR... do a memset( &buffer, 0, sizeof(TCHAR));
NG
|
|
|
|
|
I added a memset call. but i still get the src code above. this is just a piece of the src code in the middle.
I don't konw how this happen.
Thank u all here.
|
|
|
|
|
you have define UNICODE in your project
because TCHAR type will have a size of 2 bytes then....
an CFile will work different or u can send by mail(to me) your file to see where....
NG
-- modified at 10:27 Monday 5th September, 2005
|
|
|
|
|
You should allocate one more byte for '\0' char.
TCHAR* buffer = new TCHAR[1025];
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
If your pFile->Read call reads 1024 TCHAR 's, then ret has the value 1024. The line buffer[ret] = TEXT('\0'); will then overrun the end of buffer .
Software Zen: delete this;
|
|
|
|
|
when you see the content of a variable of type HWND in Watch, you see something like this: 0x00040222 {unused=???}
what is "unused"?
is HWND a class?
|
|
|
|
|
Hello,
HWND is a handle to an object managed by the OS. This means that you have no definition of the object, nor how it is implemented. This means that the object can be anything, an instance of a class, a normal struct, string, etc..
The reason why the watch has no information about the object, is because it doesn't know what to do with the handle, it doesn't know its type (handles are void* pointers). For that reason, { unused=??? } appears in the watch.
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
|
typedef void *HANDLE;
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
DECLARE_HANDLE(HWND)
HWND it`s a Smart Pointer who points into a windows table(matrix) of HWND`s(windows) ...
NG
-- modified at 8:05 Monday 5th September, 2005
|
|
|
|
|
Dear friends,
I'm facing with a problem with templates.I'm including all my code at end.The sole purpose of my program is that to use heap algorithm which will take template parameter like this
MaxHeap<array<string> > m(10);
m.initilize(a,10,10);
where String is self created class which will work same as string class and Array class main function is to use indexing starting with 1 rather than zero. The problem is that in the following line
if((c<currentsize) &&="" (heap[c]<heap[c+1]))
="" c++;
as="" my="" knoweledge="" goes="" in="" accordance="" with="" operator="" precedence="" heap[c]="" is="" worked="" out([]="" over="" loaded="" array="" class)="" and="" as="" you="" see="" the="" code="" it="" returns="" string="" object,="" according="" to="" following="" class.as="" class="" instatiated="" array<string="">, then template must do the same.The same will happen with heap[c+1] and finally < must operate on two String classes objects and < overload operator must operate and returns the int value which is furhter evaluated. But I'm getting compilation errors like this.
T& operator[](int i)
{
return data[i-1];
}
I couldnt understand why Array<class bhadram1:string=""> is transferring while comparision because in precedence it is low.I couldnt understand what is happening and i want to clear about templates. Please help me in this aspect.
compilation errors:
:\cpppractice\sep3\heap1.h(72) : error C2039: 'getPointer' : is not a member of 'Array<class bhadram1::string="">'
d:\cpppractice\sep3\heap1.h(115) : see reference to function template instantiation 'int __cdecl bhadram1::operator <(class bhadram1::Array<class bhadram1::string=""> &,class bhadram1::Array<class bhadram1::string=""> &)' being compiled
d:\cpppractice\sep3\heap1.h(72) : error C2039: 'getPointer' : is not a member of 'Array<class bhadram1::string="">'
d:\cpppractice\sep3\heap1.h(115) : see reference to function template instantiation 'int __cdecl bhadram1::operator <(class bhadram1::Array<class bhadram1::string=""> &,class bhadram1::Array<class bhadram1::string=""> &)' being compiled
d:\cpppractice\sep3\heap1.h(65) : error C2039: 'getPointer' : is not a member of 'Array<class bhadram1::string="">'
d:\cpppractice\sep3\heap1.h(117) : see reference to function template instantiation 'int __cdecl bhadram1::operator >=(class bhadram1::Array<class bhadram1::string=""> &,class bhadram1::Array<class bhadram1::string=""> &)' being compiled
d:\cpppractice\sep3\heap1.h(65) : error C2039: 'getPointer' : is not a member of 'Array<class bhadram1::string="">'
d:\cpppractice\sep3\heap1.h(117) : see reference to function template instantiation 'int __cdecl bhadram1::operator >=(class bhadram1::Array<class bhadram1::string=""> &,class bhadram1::Array<class bhadram1::string=""> &)' being compiled
Error executing cl.exe.
heap.obj - 4 error(s), 0 warning(s)
# include <iostream>
# include <heap1.h>
# include <string1.h>
using namespace std;
using namespace bhadram1;
int main()
{
int array[10]={20,12,35,15,10,80,30,17,2,1};
String str[10]={"first","second","third","fourth","fifth","sixth","seventh","eight","nine","ten"};
Array<string> a(str,10);
MaxHeap<array<string> > m(10);
m.initilize(a,10,10);
//m.print();
return 0;
}
Heap1.h file:
# include <iostream>
using namespace std;
namespace bhadram1
{
template<class t="">
class Array
{
//friend ostream& operator<<(ostream& ostr,String& s);
protected:
int size;
T* data;
public:
Array()
{
size=1;
data=new T[1];
}
Array(int n)
{
size=n;
data=new T[size];
}
Array(T* a,int const s)
{
size=s;
data=new T[size];
for(int i=0;i<s;i++)
{
="" data[i]="a[i];
" cout<<data[i]<<endl;
="" }
="" array(array<t="">& a)
{
size=a.size;
//delete[] data;
data=new T[size];
for(int i=0;i<size;i++)
{
="" data[i]="a.data[i];
" }
="" t&="" operator[](int="" i)
="" return="" data[i-1];
="" operator="(T&" a)
="" a;
="" friend="" ostream&="" operator<<(ostream&="" ostr,t&="" a);
="" int="" operator<(t&="" a1,t&="" a2);
="">=(T& a1,T& a2);
};
template<class t="">
int operator>=(T& a1,T& a2)
{
return (strcmp(a1.getPointer(),a2.getPointer()>=0));
}
template<class t="">
int operator<(T& a1,T& a2)
{
return (strcmp(a1.getPointer(),a2.getPointer()<0));
}
template<class t="">
ostream& operator<<(ostream& ostr,T& a)
{
return ostr<<a;
}
template<class t="">
class MaxHeap
{
private:
int currentSize,maxSize;
T* heap;
public:
MaxHeap(int n)
{
currentSize=n;
heap=new T[n];
}
void initilize(T a,int size,int arraySize)
{
for(int j=1;j<=10;j++)
{
heap[j]=a[j];
cout<<heap[j];
}
="" currentsize="size;
" maxsize="arraySize;
" for(int="" i="currentSize/2;i">=1;i--)
{
T y=heap[i];
//cout<<"a "<<a[i]<<" y="" "<<y;
="" int="" c="2*(i);
" cout<<"c="" "<<c<<"="" current="" "<<currentsize<<endl;
="" while(c<="currentSize)
" {
="" cout<<"sub="" "<<c<<endl;
="" if((c<currentsize)="" &&="" (heap[c]<heap[c+1]))
="" c++;
="" if(y="">=heap[c])
break;
heap[c/2]=heap[c];
c*=2;
}
heap[c/2]=y;
}
for(i=1;i<=10;i++)
{
cout<<heap[i]<<endl;
}
=""
="" void="" print()
="" {
="" }
};
};
string1.h="" file:
using="" namespace="" std;
namespace="" bhadram1
{
class="" string
{
private:
="" char*="" _string;
="" int="" _size;
public:
="" string(int="" n="0);
" string(string&="" s);
="" string(const="" );
="" string&="" operator="(String&" ch);
="" friend="" ostream&="" operator<<(ostream&="" ostr,string&="" string="" operator+(string&);
="" operator+(char*="" operator+="(String&" operator+(const="" c,string&="" char&="" operator[](int="" n);
="" operator<(string&="">(String& s);
String& operator[](int n);
char* getPointer();
};
char* String::getPointer()
{
return _string;
}
String& String::operator =(char* ch)
{
int _size=strlen(ch);
_string=new char[_size+1];
for(int i=0;i<_size;i++)
{
_string[i]=*ch++;
}
_string[i]='\0';
return *this;
}
String& String::operator[](int n)
{
return *this;
}
int String::operator<(String& s)
{
return (strcmp(_string,s._string)<0);
}
int String::operator >(String& s)
{
return (strcmp(s._string,_string)>0);
}
/*char& String::operator [](int n)
{
return _string[n];
}*/
String operator+(const char* c,String& s)
{
String temp;
temp._size=strlen(c)+s._size;
strcpy(temp._string,c);
strcat(temp._string,s._string);
return temp;
}
String String::operator +(char* c)
{
String temp;
temp._size=_size+strlen(c);
strcpy(temp._string,_string);
strcat(temp._string,c);
return temp;
}
String& String::operator +=(String& s)
{
String temp;
temp._size=_size+s._size;
strcpy(temp._string,_string);
strcat(temp._string,s._string);
delete [] _string;
_size=temp._size;
_string=new char[temp._size+1];
strcpy(_string,temp._string);
return *this;
}
String String::operator+(String& s1)
{
String temp;
temp._size=_size+s1._size;
strcpy(temp._string,_string);
strcat(temp._string,s1._string);
return temp;
}
String& String::operator=(String& s)
{
_size=s._size;
delete [] _string;
_string=new char[_size+1];
for(int i=0;i<_size;i++)
_string[i]=s._string[i];
_string[i]='\0';
return *this;
}
String::String(int n)
{
_size=n;
_string=new char[_size+1];
for(int i=0;i<_size;i++)
_string[i]=' ';
_string[i]='\0';
}
String::String(String& s)
{
_size=s._size;
_string=new char[_size+1];
for(int i=0;i<_size;i++)
_string[i]=s._string[i];
_string[i]='\0';
}
String::String(const char* ch)
{
_size=strlen(ch);
_string=new char[_size+1];
for(int i=0;i<_size;i++)
_string[i]=*ch++;
_string[i]='\0';
}
ostream& operator<<(ostream& ostr,String& s)
{
return ostr<
|
|
|
|
|
Hey, can anybody tell me how to check whether Hotfixes are installed or not thru pgm in VC++(Win SDK) when value is specified???
thanks in advance
Supriya Tonape
|
|
|
|
|
Supriya Tonape wrote:
can anybody tell me how to check whether Hotfixes are installed or not thru pgm in VC++(Win SDK) when value is specified???
All the Installed application/hotfix can be found from this registry location :-
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Yeah Alok I knew it but U didnt get my ques. I wanted to check them thru my pgm, I might need to use "RegOpenKey()" n "RegEnumKey()" funcs.
I m trying it out. hope U got my point.bye for now.
Thanks n Regards,
Supriya Tonape
|
|
|
|
|