|
hi there,
i really hope there's someone out there that can help me with my dilemma:
i need to load a jpeg image from file..encode in it base64 format and display
it on the edit box...then from there decode the data and save it in a file as jpeg. i know how to load and save the file. but i'm having a lot of problem with the base64 encoder/decoder. so, is there anyone tat knows the sourse code in Visual C++?
thx a bunch to the kind soul tat can help me!
Syazarine
|
|
|
|
|
This library[^] contains a basic Base64 encoder / decoder, thats probably a good starting point to have a look at.
You might always want to have a look the original RFC[^] for reference aswell.
Gavin Taylor
w: http://www.gavspace.com
|
|
|
|
|
I was wondering if someone could help me out with Multi-threading.
I have a Win32 dll that does some heavy scanning and performs callbacks to update a status display of my gui. I introduced multithreading into the DLL and it works fine - but the same callbacks from within the threads fail, and lock up. Outside the threads the callbacks work fine.
any ideas or sample examples of Win32 DLL Multithreading (no MFC)
Raiden
|
|
|
|
|
You're probably doing your screen updates from your threads using SendMessage , right? Unfortunately, when you call SendMessage from a thread that doesn't own the window, it switches threads to make the call. This has the effect of blocking the calling thread.
Try doing screen updates using PostMessage instead.
Software Zen: delete this;
|
|
|
|
|
Thanks for the reply Garry,
I'm actually using callbacks:
to return text from the dll to update say a label of the engines location on the gui.
dThreadCallBack is a DWORD thats stores the static members address location
void StdScanner::CallBackFunction (char *cSomeStringToSend)
{
typedef int (__stdcall* lpMyCallBack) (LPSTR szMsg);
lpMyCallBack MyCallBack;
MyCallBack = (lpMyCallBack) dThreadCallBack;
MyCallBack(cSomeStringToSend);
}
Normally this function works perfectly when outside threads, but locks up when I use it in threads.
Do you have any examples/source of generic Multithreaded Win32 DLLs (non mfc) that can interact with a gui (be it MFC or WIN32).
Raiden
|
|
|
|
|
Where is it locking up? If you break into it with the debugger and get a callstack of what's going on when it locks up this would be a big help. Note - When you write a multithreaded program you have to start worrying about the thread safety of every function you call - I suspect this may be your problem.
Steve
|
|
|
|
|
Hello All!
How do I get NT domain name under Windows 98 using Windows API ?
Sincerely Yours,
RadioShark
|
|
|
|
|
To send a message to a CWnd derived object is easy, I use SendMessage() method. Could anyone help me understand how to send message to a CCmdTarget derived object such as CDocument which owns a message table (BEGIN_MESSAGE_MAP/END_MESSAGE_MAP) ?
Perhaps I'm just going down the difficult path. Namely, I'm trying to send a "new-document" menu message to the SDI document to force cleanup and get the "option to save modified" feature. For some reason if I call OnNewDocument() method directly the framework ignors the fact that the current document is "modified". I though sending the menu message would fool the framework to do its job.
Thanks bunches
Alex
|
|
|
|
|
You could just call the menu handler directly - OnFileNew() . The other way (as you suggest) is to send a WM_COMMAND message with the ID_FILE_NEW command ID to your main window (not to the document directly).
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hello!
What are there differences between Win32 and MFC project in Visual C++ project types?
(other than we can use existing MFC classes in MFC project)
is it better that I create my project with Win32, for more security? or,
are they the same security?
please help me.
Zo.Naderi-Iran
|
|
|
|
|
zoncpp25 wrote: (other than we can use existing MFC classes in MFC project)
erm... well, the main difference with an MFC project would be that it supports MFC, obviously.
zoncpp25 wrote: is it better that I create my project with Win32, for more security? or,
are they the same security?
An MFC project is a Win32 project wrapped in a class structure that makes it easier to use. I don't see how there can be any security risk in using a framework that generates Win32 code at the end of the day. What sort of security are you worried about ? For what reason ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
security for debug and trace in an exe file that created with vc++
Zo.Naderi-Iran
|
|
|
|
|
That sounds like you have no need of security at all, unless you mean security in the sense of making your program uncrackable ( if it has some sort of licencing scheme ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I have an application(MDI) that starts out with all child window closed. Therefore, on start up, I will see the default IDR_MAINFRAME menu bar.
In CMDIApp::InitInstance, i have also created my own DocTemplate and added. This template is meant to be opened through an option I have created in IDR_MAINFRAME.
I tried to open the new view through the menu by usign CreateNewFrame of CDocTemplate, but my compiler is telling me that theApp is an undeclared identifier.
Can anyone tell me I can call my new view through IDR_MAINFRAME, or point me to where I can get a solution? Thanks!!!
|
|
|
|
|
I recently wrote a simulator for a card game, and I wanted people to have the ability to extend the default AI by writing their own. I set it up so that people could write a DLL and the simulator would look for it. However, when I run the simulator using the DLL, it crashes at the start of the 2nd hand. The wierd part is that if I copy/paste the code from the DLL to the actual simulator, it runs fine.
The problem occurs when I try to access (not dereference) a pointer which is passed to the DLL's function.
This is the code I'm using to access the dll:
string dllName = "BotAI.dll";<br />
const char* functionName = "?getBotDecision@@YA?AVAction@@AAVHandHistory@@PAVStatsDB@@_N@Z";<br />
HMODULE module = LoadLibrary(dllName.c_str());<br />
Action (*theDllFunc)( HandHistory&,StatsDB*,bool) = 0;<br />
<br />
if (!module)<br />
{<br />
cout << dllName << " not found or load failed.\n" << endl;<br />
Sleep( 10000 );<br />
exit(1);<br />
}<br />
<br />
theDllFunc = (Action (*)(HandHistory&,StatsDB*,bool))GetProcAddress(module, functionName);<br />
Action result(ACTION_Fold);
if (!theDllFunc)<br />
{<br />
cout << functionName << " not found inside " << dllName << " or load failed.\n" << endl;<br />
Sleep(10000);<br />
}<br />
else<br />
{
result = theDllFunc(hand, stats, verbose );<br />
}<br />
if (!FreeLibrary(module))<br />
cout << "error releasing the module loaded from " << dllName << endl; <br />
return result;
The strange part as I said is that it runs fine for 1 hand using the DLL for all 10 players, then hand #2 starts and it crashes while accessing a function call to StatsDB. However if I put all the code into the actual simulator and comment out all the above code, it works fine.
Note that I'm compiling the DLL with the same compiler as the simulator, and am using the same static library for the DLL as for the simulator. Also, it accesses the DLL fine for the first hand, and only crashes on the 2nd hand. Each player accesses the DLL only once per hand, so I am inclined to think it is something to do with accessing the DLL twice from the same player...or something along those lines. As I've said, it works for the entire simulation if I just copy/paste the code from the dll to the simulator, and I've done a lot of simulator testing, so that's not what's wrong. Any ideas?
|
|
|
|
|
I can't see any obvious mistakes. Can you include more details of the crash? ie. The exact line it crashes, the exception type and a stack trace of the crash is a bare minimum.
Steve
|
|
|
|
|
Hi Steve,
I just spent a long while debugging, and it seems that the app is crashing when I call clear() on an stl map which is a member variable of an object which is a member variable of StatsDB. Not sure at all why that it's happening here.
The message I get while debugging is: Unhandled exception at 0x1007619d (BotAI.dll) in Simulator.exe: 0xC0000005: Access violation reading location 0xcdcdce06.
The actual line it dies is:
void _Erase(_Nodeptr _Rootnode)<br />
{
for (_Nodeptr _Pnode = _Rootnode; !_Isnil(_Pnode); _Rootnode = _Pnode)<br />
{
_Erase(_Right(_Pnode));<br />
_Pnode = _Left(_Pnode);<br />
this->_Alnod.destroy(_Rootnode);
this->_Alnod.deallocate(_Rootnode, 1);<br />
}<br />
}Line 3 of the above pasted segment.
|
|
|
|
|
I can't see a call to clear . I not sure if the problem can be diagnosed from the code you’ve provided. Perhaps if you show the code which calls clear someone will notice a problem.
Steve
|
|
|
|
|
is BotAI your dll? if yes, that that is not the way to export and use a function from a DLL.
That name you are using i.e ?getBotDecision@@YA?AVAction@@AAVHandHistory@@PAVStatsDB@@_N@Z is a result of namemangling done by the C++ compiler and it may change if you change the compiler or change the function signature.
Best way is to use dllimport dllexport directivies so that the compiler does not do any name mangling to the function.
Read more on how to import/export functions from the dll.
-Prakash
|
|
|
|
|
|
thanks,
but its not me who wants it
-Prakash
|
|
|
|
|
Laxman9 wrote: FAILURE is the first step towards SUCCESS
FAILURE is the last step towards the PINK SLIP
Jesus Loves <marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" style="background:#99ccff;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Defeat is temporary but surrender is permanent
--Jesus is Lord
|
|
|
|
|
here is the sample..code for DLL
//header file dllexportsclass.h//
#ifdef DLLEXPORTSCLASS_EXPORTS
#define DLLEXPORTSCLASS_API __declspec(dllexport)
#else
#define DLLEXPORTSCLASS_API __declspec(dllimport)
#endif
/ This class is exported from the DllExportsClass.dll
class DLLEXPORTSCLASS_API CDllExportsClass {
public:
void show();
CDllExportsClass(void);
// TODO: add your methods here.
};
extern DLLEXPORTSCLASS_API int nDllExportsClass;
DLLEXPORTSCLASS_API int fnDllExportsClass(void);
//c++ file//
include the above header file
/ This is an example of an exported variable
DLLEXPORTSCLASS_API int nDllExportsClass=0;
// This is an example of an exported function.
DLLEXPORTSCLASS_API int fnDllExportsClass(void)
{
::MessageBox(NULL,"function","",0);
return 42;
}
// This is the constructor of a class that has been exported.
CDllExportsClass::CDllExportsClass()
{
return;
}
void CDllExportsClass::show()
{
::MessageBox(NULL,"Hello Dll","CDllExportsClass",0);
}
and include the header file into the project where u want to use the DLL.
Thanks and Regards
Laxman
FAILURE is the first step towards SUCCESS
-- modified at 0:30 Monday 30th January, 2006
Thanks and Regards
Laxman
FAILURE is the first step towards SUCCESS
|
|
|
|
|
In versions of VC++ gone by, if you clicked on a Windows identifier, e.g. WM_PAINT, and pressed the F1 button then the relevant Windows API help would be displayed.
I'm now using Visual Studio .NET 7.1, and pressing F1 on any Windows identifier always displays help for MFC instead.
If I'm using MFC then that's fine, but most of the time I'm not, so it's rather annoying. Does anyone know how to get the old-style behaviour back?
Cheers
|
|
|
|
|