|
Anyone has an ideea about opening a file from command-line in a dialog-based application ?
A link to a article or something whould be great. thanks.
|
|
|
|
|
If you want to run some DOS commands (also including opening a file) ShellExecute[^] is the way to go!
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Regardless of the type of application (dialog, SDI, or MDI), you simply need to look at the m_lpCmdLine member variable of CWinApp .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
DavidCrow, if you could extend the explications a liitle bit more, i would be gratefull. (something about WinMain call ?)
|
|
|
|
|
I'm not sure what you mean by "extend the explications," but maybe this will help.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi all,
I’m writing my first DLL. Any help would be greatly appreciated. When I run the DLL function fnCopyFile I get an error: "Unhandled exception at 0x77f5a58 in MyTest.exe." The DLL function works but this error occurs when popping out of the DLL’s fnCopyFile function.
Here is my DLL code:
Main program:
#include <string>
using namespace std;
typedef void (WINAPI *FncArcNewFile)(string str1, short si, string str2, short st);
int _tmain(int argc, _TCHAR* argv[])
{
HINSTANCE hinstLib;
FncArcNewFile FncCopy;
short iii = 4;
hinstLib = LoadLibrary(TEXT("C:\\ProgramFiles\\CasArc.dll"));
FncCopy = (FncArcNewFile)GetProcAddress((HMODULE)hinstLib, "fnCopyFile"); //Name of the function in the DLL.
FncCopy(string("c:"), iii, string("C:\\Custodian Working Dir \\0001_0001_0001_0002.txt"), iii);
FreeLibrary(hinstLib);
}
CasArc.dll program:
.H file
#include <string>
#include "CasArc.h"
#include <iostream>
using namespace std;
extern "C" __declspec(dllexport) void fnCopyFile(string pstrDir, short EVarIn_y, string pstrFile, short EVarIn_l);
.CPP file:
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
break;
}
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
extern "C" __declspec(dllexport) void fnCopyFile(string pstrDir, short EVarIn_y, string pstrFile, short EVarIn_l)
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
DWORD dwAttrs;
//*ret_indicator = 0;
hFind = FindFirstFile(pstrFile.c_str(), &FindFileData);
if (hFind != INVALID_HANDLE_VALUE)
{
pstrDir += "\\";
pstrDir += FindFileData.cFileName;
if (CopyFile(pstrFile.c_str(), pstrDir.c_str(), FALSE))
{
dwAttrs = GetFileAttributes(FindFileData.cFileName);
//if ( GetLastError() != 0 )
// ErrorMessage();
if (!(dwAttrs & FILE_ATTRIBUTE_READONLY))
{
SetFileAttributes(pstrDir.c_str(), dwAttrs | FILE_ATTRIBUTE_READONLY);
}
}
else
{
ErrorMessage();
}
}
else
{
ErrorMessage();
}
FindClose(hFind);
}
|
|
|
|
|
Hi,
I would like to know that how can i detect memory leaks in an application with information such as which file had memory leak and line number.
I have a dll which i dynamically load. That dll is using a big static library OpenSSL and i have included the DLL in the exe based project.
Now what i find through standard outputwindow after closing of application is that there are huge memory leaks like,
{18643} normal block at 0x012F8AE0, 12 bytes long.
Data: < / C IT> 20 8B 2F 01 00 00 00 00 43 E6 49 54
I want to know the exact file and line number which comes through DEBUG_NEW i think, but the library code is ansi c code and it 500 or more file so any ideas how can i debug to the exact location.
Any good memory profiler available.
Thank You.
|
|
|
|
|
Is there in this library a common header file that is always included?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
I am wondering how can I create a simple function that will return the current second,minutes and hour in a 3 dimensional int array. I been looking at the information on ctime in windows to see how I could do this but I havent found what I needed. I dont want the function to pause or anything I just want it to simply return the second, minutes and hours.
|
|
|
|
|
Check GetSystemTime
or time_t time( time_t *timer );
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Supaflyfrank wrote:
...return the current second,minutes and hour in a 3 dimensional int array.
What is this? A 3D int array looks like:
int arr[x][y][z]; How do you propose to fill that up with "second, minutes and hour?"
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
int arr[1][1][1];
perhaps...
But I can't help to think that a better way to store time is in a structure like this:
<br />
struct TIME<br />
{<br />
int m_nSeconds;<br />
int m_nMinutes;<br />
int m_nHours;<br />
};<br />
There probably is a predefined structure like that.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Bob Stanneveld wrote:
There probably is a predefined structure like that.
Several, actually.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I will look in to see if their is any structure already made. But I was more thinking of a array like this: int Time[3]; Time[0] Would be hours Time[1] Would be minutes and Time[2] Would be seconds.
|
|
|
|
|
Hi,
I am inserting a flash control in my application (Win32 API application no MFC) and now I have to implement GetMoniker of IOleObject... How can I do that?
Thank you very much in advance for your answers...
Well... I am a beginner ...
|
|
|
|
|
Hello there,
I am trying to create a modeless dialog-box dynamically, without using a resource image file. The following code illustrates my (useless) effort so far:
BOOL CDlg::Setup()
{
DLGTEMPLATE DlgTemplate;
WORD MenuNull = NULL;
WORD ClassNull = NULL;
WORD TitleNull = NULL;
int nScrHeight;
int nScrWidth;
RECT rect;
nScrWidth = ::GetSystemMetrics(SM_CXSCREEN);
nScrHeight = ::GetSystemMetrics(SM_CYSCREEN);
DlgTemplate.cx = nScrWidth / 5;
DlgTemplate.cy = nScrHeight >> 2;
DlgTemplate.x = nScrWidth - DlgTemplate.cx;
DlgTemplate.y = 0;
DlgTemplate.cdit = 0;
DlgTemplate.style = WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | DS_3DLOOK;
DlgTemplate.dwExtendedStyle = 0;
if(!CreateIndirect(&DlgTemplate))
return FALSE;
.
:
.
After calling CDialog::CreateIndirect, there is an error that occurs at WinAPI level -- Error 1813 -- The specified resource type cannot be found in the image file.
If you could please tell me what I am doing wrong here, I would greatly appreciate it!
Thank you so much,
David Nimrod
|
|
|
|
|
CreateIndirect was not provided to allow dynamic creation of dialogs like you pretend, so its interface is evily complicated. If you go to the docs for DLGTEMPLATE[^], it is said that this structure must be followed in memory by a bunch of other binary information. As you haven't provided this, CreateIndirect dives into random memory hence the result.
So, you must construct a block of memory according to what CreateIndirect expects, possibly with the minimum information necessary. What has to be written is described here[^]. Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have created a pointer to a shared memory, but I need to be able to access variables (not bit fields - they will be done by word) via an offset from the start of the memory location. I have an array of all the offsets to each variable, but dont know how to setup a pointer to the memory area and how to obtain each variable's data using this offset.
The structure contains bit fields, which must remain so cant use the offsetof macro.
#pragma pack(1)<br />
typedef struct<br />
{<br />
unsigned short i; <br />
float f; <br />
char c; <br />
unsigned short bit41 : 4;<br />
unsigned short bit42 : 2;<br />
unsigned short bit43 : 1;<br />
char s;<br />
unsigned short x;<br />
double y;<br />
double z;<br />
} SFOO;<br />
<br />
struct TSharedMemory {<br />
union<br />
{<br />
SFOO fields;<br />
unsigned short buffer[32];<br />
}test_data;<br />
);<br />
#pragma pack()
Note I have used CreateFileMapping and
MapViewOfFile, which is OK for access via the structure, but its for access via the array of offsets that I cant seem to do.
i.e. setup pointer to start of the shared memory and access via this pointer and the offsets.
Any suggestions please.
|
|
|
|
|
Whatever the way you get you offset, to access the correct member of the structure you should do:
void *pvIntrinsic pointer to your data
pvFieldPtr = ((char *) pvIntrinsic) + uOffset
Then do the correct cast on it
eg: for a double value
*(double *) pvFieldPtr = doubleValue;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks that was what I was looking for.
Just one final question regarding casting. Are they any way I can do a more generalised cast or must it be to the correct type.
Thanks again,
Sweep
|
|
|
|
|
It should be the correct cast, because the size written or read from memory is affected.
A way to solve the issue, let another member in your struct hold the type, and based on it you'll do your cast (enum like member: TYPE_INT, TYPE_FLOAT, TYPE_ ...)
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Declare a pointer to a SFOO :
struct SFOO *psfoo;
Set the pointer to the address you want :
psfoo = (struct SFOO *)( (char *)BasePointer + offset );
Then you can use standard pointer references :
<br />
psfoo->x = 42;<br />
psfoo->y = 3.141596;<br />
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
hi all.. how to display tiff and jpg images on my dialog-based application?
I search for it and they seems too complicated to understand.
I have list of file names want to display one at the time on the dialog when the user click on next or previous button. But I have no experience and no idea of displaying image on the dialog.
Can anyone please tell me how to display tiff and jpg images on dialog Please..
Thanks
|
|
|
|
|