|
i wrote a dll in vc++,which iam calling from vb app. iam creating a window when i call the function called createwindowfunction from vb.iam closing the window and i again create the window by calling that function from vb app.when i close the window,the global variables are not cleared from memory.so when i call createwindow again the values are retained.how should i close the instance and to clear the variables.i think there is some way to close the instance.
|
|
|
|
|
Global variables retain their values until you unload library. Consequently, you must use LoadLibrary and FreeLibrary to getting results, which you are expecting. AFAIK it's not easy to get function's address from DLL at runtime in VB. Then I would offer to write special function that cleans all global variables and call it explicitly... or clean your variables at window destruction
I beg pardon, if I misunderstood your question
|
|
|
|
|
You are right Mr.Roman.
i declared global variables like int char etc before the main function.if iam using freelibrary in the wm_close,then the vb application also gets closed.so i tried to use the globalfree function for int,char etc.but also the variables in memory are not released.
|
|
|
|
|
Hello, folks,
I got trouble using one of the DirectShow sample filters, i.e, Ball filter.
I got a link error. If I compiled and linked the code sample, the filter would generate something like ball.ax.
Could anyone tell me how to use this ball.ax ? I have included required *.h and ball.lib but I still got a linking error ? The linking error is as follows:
BallAppDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall CBouncingBall::CBouncingBall(struct IUnknown *,long *)" (??0CBouncingBall@@QAE@PAUIUnknown@@PAJ@Z)
../Release/BallApp.exe : fatal error LNK1120: 1 unresolved externals
Anybody help me ? Any response would be greatly appreciated ! Thanks !
|
|
|
|
|
Before you get to compile and link a DirectX sample, you need to go to MSDEV Tools \ Options \ Directories tab, and move the DirectX include/source/lib directories to the top.
|
|
|
|
|
>>DirectX include/source/lib directories to the top.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Hello, thanks for you reply first.
On my system I have installed Platform SDK and DirectX 8.0 SDK. It seems the DirectX 8.0 SDK has been integrated with Platform SDK. So, I can NOT find the
DirectX include/source/lib directory as you menthioned.
Could you explain a little more detail ? Or what should I install on my system ? Thanks for your help again.
|
|
|
|
|
manio wrote:
On my system I have installed Platform SDK and DirectX 8.0 SDK. It seems the DirectX 8.0 SDK has been integrated with Platform SDK
Depends if you have a recent platform SDK.
I would suggest to add the <directXsdk\lib> directory in MSDEV \ Tools \ Options \ Directories \ Library.
May be the problem is somewhere else. Lookup the public MS DirectShow newsgroup (or google, of course). I remember I have seen this kind of question again and again in the past, and from what I remember it was just a matter of directories.
I would suggest
|
|
|
|
|
I made a lil' app on a NT4.0 system. It works fine. But when I run my prog on a windows '98 it just didn't work. When I recompiled the prog on the '98 it worked fine. When I run it I get a c++ exception. Now, I don't think that's the big problem. The problem is that in a method like this:
void HTML::HTML_FileHeader(char* filename,char* pagehead,char* tableheader) {
fileout.open(filename,ios::trunc);
CString mesaj;
char text[100];
fileout<< "<html>\n"
"<head>\n"
"</head>\n"
"<body>\n"
"<h2 align=center>";
fileout<< pagehead;
mesaj.Format(" %d, data de %d",time.GetHour(),time.GetDay());
strcpy(text,(LPCTSTR)mesaj);
fileout<< text;
fileout<< "</h2><table border=1 align=center>\n"
"<tr>\n"
"<th>ORAS</th>\n";
fileout<< tableheader<<"</tr>\n";
}
doesn't work.
fileout.open(filename,ios::trunc); doesn't work. He doesn't like the (char *)filename. If i replace filename with the actual file that it has to open it works fine. This happens in every method of the class. He doesn't like getting that. If I debug it the content of filename is correct. This is very odd (to me).
When I create a new win32 console app and I open a file that way in the main function it works fine. !!!!
I also open databases from methods opendatabase(databasename). This also doesn't work until I replace the databasename with the actual db name "databasename".
What am I doing wrong ?????? Somebody knows anything about this problem ?
P.S. I get the c++ exception because I'm trying to open a db and since he doesn't like the arguments like that (see below) it doesn't work
DBDatabase = DBEngine.OpenDatabase ( text );
DBRecordset = Database.OpenRecordset((LPCTSTR)openstring,dbOpenDynaset,dbDenyWrite);
|
|
|
|
|
This is a problem of the filename. You should use the complete path. Maybe you should check that the file exist before you open it. (If not a messagbeox, for the alpha-release)
Remember: exception handling is best practice, get the exception message in a box.
If recompiling helps it maybe also that different version are installed on different machines. (header, code, libs, dll)
You godda puzzle some bits.
Try this @ home. (B&B)
|
|
|
|
|
I can't use the complete path. This is not a solution because I have more than one file to be opened. And I checked for the existance of the filename. And it doesn't work neither when I try to open a database the same way I do the file. And EXCEPTION HANDLING -- I got the following answer:win32 exception. That helps alot
|
|
|
|
|
I had THIS problem also, it resolved that file couldn´t be found in the release-mode, because of the working directory and relative path. Not working with the complete path isn´t good style and you have your results.
And more than one file open can also be an architectual problem. Try to handle one file or db after the other. Or merge the file / dbs.
You get an exception, because the programmer of the code you want to use had implemented it!!! Look for it!!!
Try this @ home. (B&B)
|
|
|
|
|
BlackRider wrote:
the following answer:win32 except
Try to show the value of GetLastError()
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
how can i determine whether the current user (whoever launch my exe) is "Administrator" or member of "Administrators"??
two scenario:
(a) local user
(b) active directory user
Thanks
norm
|
|
|
|
|
static inline BOOL IsAdmin(void) {
HANDLE hToken;
DWORD dwStatus;
DWORD dwAccessMask;
DWORD dwAccessDesired;
DWORD dwACLSize;
DWORD dwStructureSize = sizeof(PRIVILEGE_SET);
PACL pACL = NULL;
PSID psidAdmin = NULL;
BOOL bReturn = FALSE;
PRIVILEGE_SET ps;
GENERIC_MAPPING GenericMapping;
PSECURITY_DESCRIPTOR psdAdmin = NULL;
SID_IDENTIFIER_AUTHORITY SystemSidAuthority = SECURITY_NT_AUTHORITY;
__try {
ImpersonateSelf(SecurityImpersonation);
if (!OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, FALSE,
&hToken)) {
if (GetLastError() != ERROR_NO_TOKEN)
__leave;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY,
&hToken))
__leave;
}
if (!AllocateAndInitializeSid(&SystemSidAuthority, 2,
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0, &psidAdmin))
__leave;
psdAdmin = LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
if (psdAdmin == NULL)
__leave;
if (!InitializeSecurityDescriptor(psdAdmin,
SECURITY_DESCRIPTOR_REVISION))
__leave;
dwACLSize = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) +
GetLengthSid(psidAdmin) - sizeof(DWORD);
pACL = (PACL)LocalAlloc(LPTR, dwACLSize);
if (pACL == NULL)
__leave;
if (!InitializeAcl(pACL, dwACLSize, ACL_REVISION2))
__leave;
dwAccessMask= ACCESS_READ | ACCESS_WRITE;
if (!AddAccessAllowedAce(pACL, ACL_REVISION2,
dwAccessMask, psidAdmin))
__leave;
if (!SetSecurityDescriptorDacl(psdAdmin, TRUE, pACL, FALSE))
__leave;
SetSecurityDescriptorGroup(psdAdmin, psidAdmin, FALSE);
SetSecurityDescriptorOwner(psdAdmin, psidAdmin, FALSE);
if (!IsValidSecurityDescriptor(psdAdmin))
__leave;
dwAccessDesired = ACCESS_READ;
GenericMapping.GenericRead = ACCESS_READ;
GenericMapping.GenericWrite = ACCESS_WRITE;
GenericMapping.GenericExecute = 0;
GenericMapping.GenericAll = ACCESS_READ | ACCESS_WRITE;
if (!AccessCheck(psdAdmin, hToken, dwAccessDesired,
&GenericMapping, &ps, &dwStructureSize, &dwStatus,
&bReturn)) {
printf("AccessCheck() failed with error %lu\n", GetLastError());
__leave;
}
RevertToSelf();
} __finally {
if (pACL) LocalFree(pACL);
if (psdAdmin) LocalFree(psdAdmin);
if (psidAdmin) FreeSid(psidAdmin);
}
return bReturn;
}
This is what I use to check for domain Admins. I found it on MSDN somewhere I don't recall and adapted for my specific use. You can use it as a starting point.
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
thanks, mind the send me the MSDN link so i can look up the needed library and such?
also, do u know if it's good for WIN NT? or just 2000 and up?
norm
|
|
|
|
|
Sorry, before I posted it I tried to search MSDN for the original code and no success, but I could not take the credits for a function I did not write.
I only tested it on Windows 2000, under NT style domains and Active Directories, but I think there's nothing tying it to Windows 2000, it should work on NT, too.
The way to go will be checking each function for Windows NT compatibility on MSDN.
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
Hi,
I have an ATL which is creating a thread. This thread will have to send some messages.
I don't know exactly how to do it but I would like to create (I guess during the initialisation of my ATL) a window (which won't be visible) and which will receive the messages sent by the thread.
So here are my questions :
- How to create, without using MFC, a window in my ATL control.
- How to send a message from my thread that will be received by the window ?
Thank you for your help !
Jerome
|
|
|
|
|
|
I am having some troubles going about detecting when the user presses '^' (SHIFT+6). There aren't any virtual key codes for the shift+characters. I can dectect when the shift key is pressed but have problems after that. I tried checking to see if the lParam of the MSG structure was VK_6 but that just gave me an error saying VK_6 is an undeclared identifier (but to be honest, I don't the lParam was what I should have been looking at to start with).
This is the line code PreTranslating the shift key:
if( WM_KEYDOWN == pMsg->message && VK_SHIFT == pMsg->wParam )
Anyone got any suggestions to point me in the right direction. The fact that VK_6 is coming up undelcared leaves me at a loss. I'm starting to suspect that the shift+[key] are VK_UNDEFINED which is really going to suck. I will also be needing to get the '@'.
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
- Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler <
|
|
|
|
|
Do you *need* to detect it in PreTranslateMessage ? Will OnChar do, or OnKeyDown ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Actually, OnChar or OnKeyDown would be fine as well. Was having problems getting the '^' detected (ASCII 0x5E). I knocked this out. A little clumsy but does the job. What I'm doing is dis-allowing the '^' as valid input as I have device that uses that uses the character internally so allow the user to type that into the data going in will cause problems. Basically I was thinking that I would send out a MessageBox each the user hit one of the invalid keys reminding them what they can't use and returning the edit at the same location that the char was typed (minus the char of course). This works but as I said, its clumsy - I was more looking to get something working in a hurry so I could move on with it working:
<br />
BOOL CRHTC100Dlg::PreTranslateMessage(MSG *pMsg)<br />
{<br />
if( WM_KEYDOWN == pMsg->message && 0x36 == pMsg->wParam && m_nShiftFlag )<br />
{<br />
return TRUE;<br />
}<br />
else;<br />
if( WM_KEYDOWN == pMsg->message || WM_KEYUP == pMsg->message)<br />
if(VK_SHIFT == pMsg->wParam)<br />
m_nShiftFlag = 1;<br />
else<br />
m_nShiftFlag = 0;<br />
return( CDialog::PreTranslateMessage( pMsg ) );<br />
}
I'll likely take a stab using OnKeyDown (if I can detect the '^') as it should save me from have to go back and remove the char and adjust the cursor postion. How was the weekend?
[edit]I just figured that using PreTranslateMessage was going be the least amount of effort on my part but I mis-guessed on that considering the difficulty it gave me (twenty minutes on that was at least 15 to many).[/edit]
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
- Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler <
|
|
|
|
|
In OnChar, the first parameter is a UINT. If you declare a char to be equal to that value, you can test for any key you like:
<br />
void CTestView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)<br />
{<br />
char c = nChar;<br />
CString s(c);<br />
AfxMessageBox(s);<br />
}<br />
This will bring up any key you press in a message box.
The conversion from int to char is implicit.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Mel Feik wrote:
I'll likely take a stab using OnKeyDown
WM_KEYDOWN sends a VK code, but WM_CHAR sends the actual char, from what I can tell. I am using MFC7 ( and that means adding message handlers manually BTW ), but I think the wParam value in WM_CHAR will work the same as the UINT in my code sample.
Mel Feik wrote:
How was the weekend?
Parts were great, parts were awful. The average of all tabulated values is probably 'fair to middling'. I saw you were working ? Is my code working for you yet ?
Mel Feik wrote:
I just figured that using PreTranslateMessage was going be the least amount of effort on my part
I am sure WM_CHAR will work easily. I always try to avoid PreTranslateMessage if I can.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
I saw you were working ? Is my code working for you yet ?
Nope... I am supposed to have my CD's back for my enterprise/architect back tomorrow by 4 pm. Had to have my brother overnight it to me Saturday. I'm looking forward to, it been rough not being able to do certain things on this SE version. Been challenging though.
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
- Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler <
|
|
|
|
|
The VK code for '6' is the same as the ASCII char value; to check for the Shift key being pressed you could GetKeyState() function (GetKeyState(VK_SHIFT)).
Regards,
Cosmin
|
|
|
|
|