|
You can add any resource via the resource editor ( Right Mouse click > import)
and for extracting...look the code below
UINT uSizeOfDll;
DWORD dwSizeOfDllInBytes;
DWORD dwBytes = 28672; //size of my resource
try
{
HRSRC hRes;
hRes = (HRSRC)::FindResource(
NULL,
MAKEINTRESOURCE(IDR_DLL1),
"DLL");
if (hRes == NULL )
{
DWORD dwErr = GetLastError();
return FALSE;
}
HGLOBAL hGlobal;
hGlobal = :: LoadResource(NULL,
hRes //Res Handle
);
if (hGlobal == NULL)
{
DWORD dw = GetLastError();
return FALSE;
}
//lock the file into global Memory
char *lpMem;
lpMem = (char*)LockResource(hGlobal); //File Pointer
if (lpMem == NULL)
{
DWORD dw = GetLastError();
return FALSE;
}
HANDLE hFile;
hFile = (HANDLE)CreateFile(m_szDllPath, //#name
GENERIC_READ|GENERIC_WRITE,//#Access
FILE_SHARE_READ | FILE_SHARE_WRITE,//#share
NULL, //$ def Security
CREATE_ALWAYS,//creation disposition
FILE_ATTRIBUTE_NORMAL, //attr
NULL//# templateFile
);
if (INVALID_HANDLE_VALUE
== hFile)
{
return FALSE;
}
DWORD dwWrritten = 0;
int nRes =
::WriteFile
(hFile,
(char*)lpMem,
dwBytes,
&dwWrritten,
NULL);
if (nRes == 0 )
{
DWORD dw = GetLastError();
}
CloseHandle(hFile );//# close file handle
}catch(...)
{
return FALSE;
}
Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.
|
|
|
|
|
See if this article helps.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi guys
What I have to do to change de default directory in a SDI app when I click in the menu Open?
I want to control the directory where the Open dialog opens to select the file.
Thanks
Doc
|
|
|
|
|
Override the DocManager::DoPromptFileName() method. That is where the CFileDialog object lives.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks David
Have I to do that, creating a new CMyDocManager class?
Doc
|
|
|
|
|
Derive your class from CDocManager just like you would any other:
class CMyDocManager : public CDocManager
{
public:
virtual BOOL DoPromptFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate);
}; Add the following in InitInstance() before creating any doc templates:
m_pDocManager = new CMyDocManager;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
A little more difficult thhan expected, (due to _AfxAppendFilterSuffix) but I finally reached my target.
Thanks a lot
Doc
|
|
|
|
|
Hi! I need help with a little problem. I'm using the cListCtrl and i was wondering if there's a way to resize the width of the listbox dynamically? I tried searching but only found topics on resizing column widths. Please help...Thanks a lotü
|
|
|
|
|
Since a CListCtrl is derived from CWnd , it can be resized using MoveWindow() .
CRect rectListCtrl;
m_myListCtrl.GetWindowRect (&rectListCtrl);
ScreenToClient (&rectListCtrl);
rectCtrl.right += 20;
m_myListCtrl.MoveWindow (&rectCtrl);
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ok thanks! But how do i get myListCtrl to behave like the main window? e.g. id i resize the window, my list should resize as well, and if i maximize my window the list should do the same. Given that the list occupies the whole window.....thanks againü
|
|
|
|
|
I've receive this error code when im trying to build the dll file. Does any know what is this error and how can i solve it? Thank you
best regards
Snowy
|
|
|
|
|
It's hard to say without looking at your source code, but the compiler is informing you that it encountered a semicolon (; ) when it was expecting something else. The error may be fixed by inserting the expected entity before the semicolon.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
It looks like a misplaced comma. The compiler should have indicated what line is in error.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Snippet with offending line and couple of lines before could help. Otherwise it is impossible to tell what it causing it.
It maybe a missing bracket or even macro. It can be undefined and defined differently elsewhere, causing compilation problems.
JohnCz
|
|
|
|
|
I have a problem. For 2 years i've been developing an application which someone else did before me (job thing), and someone else did before him...
Well. Everything is OK, but when I want to Browse Info (to see base classes etc) i get an error without any explanation. It only says:
Creating browse info file...
Error executing bscmake.exe.
***.exe - 1 error(s)
ANy ideas?
Love is the law, love under will.
|
|
|
|
|
please?
Love is the law, love under will.
|
|
|
|
|
Hello, everyone. I met a problem days ago. I used the webbrowser to play the powerpoint file. but when I set focus to the Webbrowser window which is playing powerpoint, I cannot get any key strokes even if in the thread message queue.
where's wrong? can anybody help me? Thanks very much!
|
|
|
|
|
Consider the following code snippet..f1,f2 and f3 are functions.
int f1(int,int);int f2();int f3();
here f3 is a library function,so i don't have access to it's internal code.
int a = f1(f2(),f3());
now,i want to stop execution of f2(and f1) if f3 returns a non zero value..how can i do this on the run i.e thru code ?
thanks in advance
|
|
|
|
|
Can't you simply do this:
int Return = f3();<br />
<br />
int a = 0;<br />
if (Return == 0)<br />
a = f1(f2(), Return);
|
|
|
|
|
yea it's possible but i was asked to do it without inserting any other statement than f1(f2(),f3())..i.e check should be after call to f1 is made but not in code of f3 since it is a library function.
|
|
|
|
|
int a = f1(f2(), f3() != 0 ? throw 0);
Does that work?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
have f3 throw an exception if it's about to return anything other than a zero.
|
|
|
|
|
hi every body
i have problem with this code :
////////////////////////////////
///code in delphi
function doGetStat(aCallBackStatsParser:dfCallBackStatsParser; var strError:string):boolean;
var startTime : DWORD;
begin
result := true;
if SysHandle=0 then exit;
startTime := GetTickCount;
repeat
if abs(GetTickCount - startTime) > 1000 then break;
// Have driver fill Stats buffer with information
if not DeviceIoControl(SysHandle, IOCTL_FILEMON_GETSTATS,
nil, 0, @Stats, sizeof(Stats),
StatsLen, nil) then begin
strError := 'Couldn''t access device driver. errorCode ='
+IntToStr(GetLastError);
result := false;
exit;
end;
if StatsLen=0 then break;
if assigned(aCallBackStatsParser) then aCallBackStatsParser;
until false;
end;
//////////////////////////////////////
// Code in VC
BOOL CDriverApp::doGetStatvoid(*aCallBackStatsParser)(void) , CString *strError)
{
DWORD startTime ;
result = TRUE;
if (SysHandle==0 ) return FALSE ;
startTime= GetTickCount() ;
while(TRUE)
{
if( abs(GetTickCount() - startTime) > 1000 ) break ;
// Have driver fill Stats buffer with information
if (! DeviceIoControl(SysHandle, IOCTL_FILEMON_GETSTATS,
NULL, 0, &Stats, sizeof(Stats),
&StatsLen, NULL) )
{
strError->Format("Couldnt access device driver.\n errorCode = %d" ,GetLastError()) ;
result = FALSE ;
return FALSE ;
}
if(GetLastError()== ERROR_INSUFFICIENT_BUFFER)
strError->Format("small buffer") ;
if ( StatsLen == 0 ) { return result ;}
if (aCallBackStatsParser!= NULL) (*aCallBackStatsParser)() ;
}
return TRUE ;
}
///////////////////////////////////////////
it is working in delphi but not in VC
why ??
|
|
|
|
|
Hello all.
Now I am doing UML application.
But I cannot decide that HOW "add text to a rectangle"
HELP ME
|
|
|
|
|
hiho
i'm using a visual c++ .net setup project to install my software
the problem is that the installation can only be done my an administrator because it writes in the c:\program files\... directory
so i want that if the user installs my prog, the radio button for 'install for actual user' is set to 'install for all users'
because if the user installs my app with admin rights, it only installs for current user (if the user doesn't check the radio button to all users)
and the current user is the admin
is there a setting in the setup project, where i can change the pre-definition for the radio button?
i've not found one
and is there a way to automatically deinstall the software if it is already installed, before newly installation
because my setup aborts if the software is already installed
thx
|
|
|
|