|
fun1()
{
CreateThread(NULL, 0, &myThread, NULL, NULL, &lpThreadId);
}
/// \brief <保存序列采集得到的buffer数据到文件>
unsigned long __stdcall myThread(void *wParam)
{
//new a db record and error.
}
Happy Gemini
|
|
|
|
|
I find the context below in msdn:
"DAO itself is not multithreaded, so you can’t use the MFC DAO classes in multiple threads. Confine your DAO code to a single thread of execution."
I thank maybe it is where error is.
Happy Gemini
|
|
|
|
|
How to get the database table's struct, include it's size of fields.
I use ado2 provided by the site, but I find the size of data type, 'bit', is not correct. In SQL server, its size is 1, but what I get by ado class is 2?why?
I want to do a ETL tool, How to handle the variant data type for transforming.
|
|
|
|
|
Hi!
in the a function of a dialog i've got below code:
It's a part of seeking local computer names, when I click a button.
If i click the button, a dialog box is created and the new one shows up.
But no one can be showed in a list control view of the dialog box on Windows 98.
It hasn't nothing in the list control...
but It can be shown the list on Windows 2000 or XP.
Is the problem here?
Should i put everything in a codes?
Thanks!
noname_function ()
{
// WNetOpenEnum parameters
DWORD dwScope = RESOURCE_CONTEXT;
NETRESOURCE *NetResource = NULL;
HANDLE hEnum;
// WNetOpenEnum for Windows 98
unsigned long strWNetMSG = WNetOpenEnum(dwScope, RESOURCETYPE_ANY, NULL, NULL, &hEnum);
// WSADATA wsaData;
WSAStartup(MAKEWORD(1, 1),&wsaData);
//
if (hEnum)
{
// paremeters for WNetEnumResource
DWORD dwCount = 0xFFFFFFFF;
DWORD dwBufferSize = 16384;
LPVOID lpBuffer = new char[16384];
// continues a network-resource enumeration
unsigned long strWNetResourceMSG = WNetEnumResource(hEnum, &dwCount, lpBuffer, dwBufferSize);
NetResource = (NETRESOURCE*)lpBuffer;
// Earase items in List control
if(m_ListSearchPc.GetItemCount() != 0)
m_ListSearchPc.DeleteAllItems();
m_dwCountTotalPc = 0;
for(unsigned int i = 0; i < dwCount; i++, NetResource++)
{
if (NetResource->dwUsage == RESOURCEUSAGE_CONTAINER && NetResource->dwType == RESOURCETYPE_ANY)
{
if (NetResource->lpRemoteName)
{
CString strFullName = NetResource->lpRemoteName;
// delete \\
if (strFullName.Left(2).Compare("\\\\") == 0)
strFullName = strFullName.Right(strFullName.GetLength() - 2);
// Insert a Local network pc name to List control
if(strFullName.IsEmpty())
continue;
// 1. number
CString pcNo;
pcNo.Format("%d", m_dwCountTotalPc + 1);
m_ListSearchPc.InsertItem(m_dwCountTotalPc, pcNo);
// 2. PC name
strFullName.MakeLower();
m_ListSearchPc.SetItemText(m_dwCountTotalPc, 1, (LPCTSTR)strFullName);
m_dwCountTotalPc++;
////////////////// -->> Nothing in the ListCtl
}
}
}
delete lpBuffer;
WNetCloseEnum(hEnum);
}
WSACleanup();
}
|
|
|
|
|
Hi all,
re-posting because of no reply
I am using the RegisterHotKey() function in a dll.
RegisterHotKey(hWnd,GlobalAddAtom(buff),MOD_ATL|MOD_CONTROL|MOD_SHIFT, vkKey) ;
where vkKey is some virtual key. and buff is some char string generated using system time.
and when I try to capture this event in WM_HOTKEY, none of the combination of vkKey is working , also when i press vkKey without any combination the event is not fired.
My goal is to get notification from when vkkey is key pressed with and without combination.
Thanks in Advance.
Abhishake
|
|
|
|
|
Your code defines a single hotkey that will produce the WM_HOTKEY message when the key is pressed simultaneously with Alt, Control and Shift all held down.
You probably need to call RegisterHotKey six times: once for every combination of Alt, Control or Shift held down.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I want that my software is not available to the user, unless the user pays for an unlock code which unleashes all the power of the software. One simple e-mail with the unlock code will be enough to deliver my full software to any part of the world.
How to do it with VC6++?
thanx.
http://www.51wit.com
|
|
|
|
|
I would assume that you would have to implement some sort of registration into your software. You would create the key that you email off to a user who then plugs it into your software. Verification and validation of that key would be part of your software.
But how would stop someone from passing that key on to another non-registered user?
One way would be to ship a dongle with your software. Hardware component you plug into a parallel port (for example), which your software reads and validates.
Another would be to create a key, based on the computer name. Then implementing code in your app that verifies whether the computer the software is running on is the same as the computer for which the key was generated.
|
|
|
|
|
to Jubjub:
I want to use hard disk serial code to create a key, but I don't how to implrment code in my app? And how to generate a key? And how to know that if software is registerd?
Do you have sample or demo?
thanx.
http://www.51wit.com
|
|
|
|
|
Hi toowit,
no I'm sorry I don't have a sample or demo, as I don't use this for any software that I wrote. I've only ever seen it used in companies that I have worked for.
Well, you'd have to come up with an algorithm to create this code based on harddisk serial code (although what happens when a client upgrade their harddisk???). I would then encrypt that based on a cryptographic key known by you and you only. You can then send that to the user via email.
The user cut-n-pastes this serial number into your application, where your application goes and gets the harddisk serial code, decrypts the serial number you sent and compares them. If they match, you can store the encrypted serial number in some location (eg registry, config file, xml file, database.. etc), for retrieval everytime you start the program.
I don't know of any code that you can just plug into your apps to get it to do this stuff. But there are a lot of article on CP, so there may be something for you. The advantage of writing this stuff yourself (ie the algorithm) is that it makes it that much harder to crack.
Jubjub
|
|
|
|
|
To Jubjub:
Great appreciation to you!
Can you tell me a lot of links or reference about this?
http://www.51wit.com
|
|
|
|
|
I don't expect you will find much code out there that you can use. It is very hard (as in phd's get it wrong all the time) to create something like this that isn't easy to break. So nobody shares their code as sometimes that is the only thing protecting them.
Read Applied Cryptography, if you read between the lines it will at least prevent you from making stupid mistakes.
Depending on how much effort you feel this is worth, you can get more and more complex. However coimplexity doesn't mean that your system is any better. Remember, the bad guys can disassemble code.
The company I work for uses the keys to allow us to ship a demo, and depending on what you buy we enable more features. However it is understood that any cracker who couldn't break our scheme isn't worth the name. We are just keeping the honest people honest.
One warning: don't make this too intrusive. I know people who buy legitimate copies of software, put it on a shelf. Then they go to the pirates and get an illegal copy that they actually run, just because the illegal copy isn't so intrusive. Harddrive keys work, but they are annoying, and belive it or not, not every system has a harddrive. (though you can likely ignore those few systems without one)
Hardware dongles are worse, some comptuers don't have USB ports. They often interfer subtilly with printers on the printer port. (or worse a non-printer device) And you have just thrown away the (small) market for people who use Wine to run your program under linux, (I'm assuming you target windows) not something you should do if you can help it. Last, the libraries to use dongles are not always bug free, in some cases your program is much less reliable just because of all the problems the dongles cause. That said, there is a time and place for a hardware dongle, if you are one use them, just beware of the downside.
|
|
|
|
|
how could I disable the function when I click escape, dialog auto close.
just like overwrite OnOk() function?
but it seems there's no OnEscape()
|
|
|
|
|
The function you are looking for is OnCancel . Add a button with the ID IDCANCEL if you don't already have one, double click it to create a handler (in MSVC++ 6.0). Remove the call to the base class OnCancel and - finally - remove the button if you don't need it (although of course not the handler )
|
|
|
|
|
hmmm, if I overwrite OnCancel function, Esc key terminating the application is disabled, but I also can't terminate the application by click the top right cross button. What I want is just disable the key meanwhile the cross button still works.
|
|
|
|
|
Then you might want to kill the keypress as early as possible, adding the virtual function PreTranslateMessage :
BOOL CSomeDlg::PreTranslateMessage(MSG* pMsg)
{
BOOL result = FALSE:
if( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE )
result = TRUE;
else
result = CDialog::PreTranslateMessage(pMsg);
return result;
}
|
|
|
|
|
yes, this is what I want, thanks
|
|
|
|
|
HI ,,
i m using CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
but compiler gives error Undecleared Identifer.
while i m using its header file and lib file
but CoInitialize gives no error
wets problm
thanx
|
|
|
|
|
Add this to a header file.
#define _WIN32_DCOM
Kuphryn
|
|
|
|
|
My apologies if you already answered this question, but I've looked all over the web and in book stores for information on how to get the html content of a webpage that was Navigated to with the CHtmlView class. To be more clear, I am using a CHtmlView class and navigating to a webpage on a specific server that I maintain. That webpage does some serverside work and gives me a new webpage. This new webpage will display some data that I need to process before moving on to do something else within the application. Any hints suggestions or solutions as to how to get this data while using the CHtmlView class would be greatly appreciated. Other solutions are welcomed as well. Thank you.
Sincerely,
Testtests
|
|
|
|
|
Hi there,
Firstly, override the OnDocumentComplete virtual function (event), then we can get access to the DOM, e.g.
virtual void OnDocumentComplete(LPCTSTR lpszURL);
void CMyHTMLView::OnDocumentComplete(LPCTSTR lpszURL)
{
USES_CONVERSION;
MSHTML::IHTMLDocument2Ptr spDoc(this->GetHtmlDocument());
if (spDoc)
{
MSHTML::IHTMLDocument3Ptr spDoc3 = spDoc;
if (spDoc3)
{
MSHTML::IHTMLElementPtr spElem = spDoc3->getElementById(_bstr_t("idDataCell1"));
if (spElem)
{
CString strValue = W2T(spElem->innerText);
}
}
}
CHtmlView::OnDocumentComplete(lpszURL);
}
With the above code, remember to import the MSHTML type library to help give us smart pointer wrappers around the interfaces, e.g. insert into your views .h file
#import <mshtml.tlb> no_auto_exclude
Also, we use are performing unicode conversion here (macros USES_CONVERSION and W2T) so dont forget to add:
#include <AFXPRIV.H>
into your stdafx.h file.
I've assumed that the document returned has tags labelled with ID's - if this isn't how the data is 'structured' then you need to give me an example of the HTML. We can use the DOM to recurse through the hierarchy to retrieve the information you want. I must point out though, if you can use ID's then this is the preferred approach.
Hope this helps,
Andy
|
|
|
|
|
Thanks Andy. I'm trying to use what you gave me, but I'm such a dolt I still don't know how to use it to process the info. I think my problem is I am really confused as to how a doc/view app works (any one give me a hand?). Anyway, right now, I made the strValue a member of the CmyHtmlView class so I can get acess to it. I'm trying to display it so I can see what's inside it with a dialog but I'm having a fun time trying to play with the CString class. If you or anyone have an easy way of getting at the webpage (which is just "1" to get the value, that would be cool.
Sincerely,
Testtests
|
|
|
|
|
Hi again,
If the value is just in the body, then the following code will work...
void CMyHTMLView::OnDocumentComplete(LPCTSTR lpszURL)
{
USES_CONVERSION;
MSHTML::IHTMLDocument2Ptr spDoc(this->GetHtmlDocument());
if (spDoc)
{
CString strValue = W2T(spDoc->body->innerText);
}
CHtmlView::OnDocumentComplete(lpszURL);
}
I'm not sure what you are trying to achieve though? Is the HTML View being used to display information to the user or as a way of sending information from the web server to your application? (a web service if you like)
You say, also, that you are creating a dialog to display the value - is this something that will feature in your application or is it just for your benefit? If so, are you not developing in debug? You can also use AfxMessageBox if you want to display information quickly - just remember to remove them in production code
Hope this helps,
Andy
|
|
|
|
|
Thanks again Andy,
Basically, I have an initial webpage that CHtmlView initially navigates to. From this webpage, they type in a special key and submit it by clicking a button on the form. This webpage then in turn posts the data to an ASP webpage that does some work with a database to check if this special key exists or not in its database. It replies back a 1 if it exists and a 0 if it doesn't. It is based upon these replies that the application must now decide to allow the user to retry entering the special key or to allow the user to move forward in the application. All in all, the processing is to determine the success or failure of the special key so the program will know how to react.
I hope this clears up some confusion. Thanks for your input Andy. I really appreciate it and look forward to hearing from you again.
Sincerely,
Testtests
|
|
|
|
|
Hi,
The first problem I guess is that the user will see a page in the HTML view with the contents '1'. A better approach would be that the page returned by ASP would be more user friendly, e.g.
<html>
<body>
<h1>Key incorrect</h1>
<input type='hidden' value='1' id='idRetVal'>
</body>
</html>
So the page returned would have visible information for the user and a hidden element for the application to use. Because we've given the element an id, you can use the code I gave you at the beginning to get the value.
Once they've entered a valid key, what should your application do next? Is the interface of your application all through HTML, e.g. once verified you then display the next HTML page in the view? If so, is there a reason why you are using C++?
Or is the HTML view purely for verifying the key is valid?
If the first statement is true, have you thought about using an Internet Explorer HTML application?
Let me know
Cheers,
Andy
|
|
|
|
|