|
I want to create a new process, but I don't want to do anything with it. Just fire up an executable and send it on it's way. This is the code I'm using. I'm not leaking memory in any way, right? This is an acceptable way to do it, right? I just want to be sure... Thanks in advance
HANDLE hProcess = NULL;
SHELLEXECUTEINFO shellInfo;
::ZeroMemory(&shellInfo, sizeof(shellInfo));
shellInfo.cbSize = sizeof(shellInfo);
shellInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shellInfo.lpFile = "executable.exe";
shellInfo.lpParameters = ".\\readme.txt";
if(::ShellExecuteEx(&shellInfo))
{
hProcess = shellInfo.hProcess;
::CloseHandle (hProcess);
}
--
Peace,
Amit Jain
|
|
|
|
|
There is a nice article on CListCtrl located here:
http://www.codeproject.com/listctrl/listctrldemo.asp
When I run the demo, I have the following problems that are just driving me nuts.
1. The top grey bar for each column is 1 line height. Is there any way to make that grey bar 4 lines of height and put more text for the column header??
2. If I pick on the column divider and move it, I lose the column header label. How can I retain the column header?? I can't call InsertColumn again.
3. Is there any way of making a horizontal scrolling for each column, if it needs it? If there is too much text, it just cuts it off and the user can't scroll to see it the rest of the text.
Please, please, any response any one can give me will be greatly appreciated. My email address is brinasas@yahoo.com
Sincerely,
Danielle Jenine
|
|
|
|
|
I'm more or less jumping the gun instead of digging around alittle more, but does any know how to draw on a CTreeView? I have an SDI app and I've put stuff in the OnDraw function, but it never gets called for some reason. I want to be able to draw/paint anything in the window, even if it covers the tree display.
===================
Eric "ArchV" Fowler
Ritual Entertainment
|
|
|
|
|
|
I tried... then it doesn't draw the Tree Control itself. I tried calling the base class CTreeCtrl::OnPaint... didn't work either. And actually, the process of adding the OnPaint function from the classwizard causes the tree not to display, even if I don't change anything.
|
|
|
|
|
If you want to use TreeView's implementation of a WM_PAINT message and add your own, use this:
CMyTreeCtrl::OnPaint()
{
Default();
CClientDC dc(this);
}
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hi,
I need to create a word add-in, (just add a new menu and some event handling).
Does anyone know where i can get some samples?
The only MSN article i could find was on using the Word Development Kit, no longer supported or suitable.
Believe it can be done through COM, I Need to support office 97 onwards.
Please Help!
Richard
|
|
|
|
|
|
Hi,
I need to create a word add-in, (just add a new menu and some event handling).
Does anyone know where i can get some samples?
The only MSN article i could find was on using the Word Development Kit, no longer supported or suitable.
Believe it can be done through COM, I Need to support office 97 onwards.
Please Help!
Richard
|
|
|
|
|
Do a search for Comaddin on MSDN and you'll find a basic COMAddin that adds a toolbar and handles some events. Its a great template to use for building addins.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
I have a ATL class with one member function.
If i invoke a thread from the member function passing the 'this' pointer as the CreateThread() parameter the data is invalid when the parameter is casted back inside the thread function.
A test app demonstrating the problem is available on http://www.codeit.dk/christian/threadtest.zip
Like this
// This is my member function which
// is invoked from within my vb test app
STDMETHODIMP Cxx::yy() {
DWORD dwID=0;
// I put some data into a member variable
m_dwFoo = 200873;
::CreateThread(NULL, 0, _TheThread,
(LPVOID)this, 0, &dwID);
return S_OK;
}
static DWORD WINAPI _TheThread(LPVOID lpv)
{
// Cast the lpv pointer back to a class instance
// (the this pointer)
Cxx* p = (Cxx*)lpv;
// Now p->m_dwFoo is corrupted with an invalid value!!
return 0;
}
If I invoke the thread method from within 'OnFinalConstruct()' everything is peachy. It only happens when it is invoked from within a exposed automation method.
The class is declared a free-threaded in the registry.
Any clues?
Christian Skovdal Andersen
|
|
|
|
|
Hiya,
at first - Visual Basic only supports Apartment-model even if "free threaded" is preferred in registry. When you create additional threads in your COM app, care must be taken when calling any methods/events from that threads.
Without looking into sample code, i would guess the apartment instance pointer, your 'this' must be wrapped/marshalled in some way when it was invoked from the STA vb app (in a free threaded app, it would be marshalled for the random RPC thread). This means the interface pointer is a temporary one (limted lifetime and scope) than the CreateInstance()/OnFinalConstruct() one.
When you CreateThread(), the (worker)thread function itself is not guaranteed to execute with the supplied 'this' while the method scope isnt left. When the method scope is left with "return S_OK", the internal COM/RPC invocations are returning too, possibly destroying any temporary (interface) pointers, freeing memory etc.
The case that OnFinalConstruct() works may be an exception, possibly COM-apartment issues. You may compare both 'this' pointers (from OnFinalConstruct() and method invocation).
If you *really* need additional threads in your COM server, then follow the threading rules (marshal interface ptrs or synchronize via postmessage to main STA thread or use static instance 'this'). There exist some MSDN articles regarding asynchronous COM and threading.
Hope this helps,
A. Focht
|
|
|
|
|
I think you must differntiate between interface pointers and 'this' pointers.
If 'this' pointers where to be marshaled it would mean new instances of the objects had to be created.
My bet for the original bug posted is that the last instance to the object is released before the thread function is trying to access the supplied this pointer parameter.
|
|
|
|
|
You are absolutely right!
I tried to change my vb variable holding the object to a global instance, and it worked like a charm!
Apparently Visual Basic dereferences the interface pointer when leaving scope.
Thanks for helping me out
Christian Skovdal Andersen
|
|
|
|
|
I have experienced similar problems due to the type casting back to your class not resulting in the correct vtable.
The class I passed had multiple inheritence. In order to fix the problem, I first had to cast the LPVOID to the base class, and then once again cast that resulting pointer into the desired class.
Anyhow, that is what worked for me.
|
|
|
|
|
I'm creating a Connection like this:
m_Connection.CreateInstance(__uuidof(Connection));
CComBSTR conStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
conStr.Append(DatabasePath);
bstr_t con(conStr);
TESTHR(m_Connection->Open(con, "", "", adConnectUnspecified));
and then trying this in another method:
if (m_Connection == NULL)
return S_FALSE;
_RecordsetPtr records = NULL;
records.CreateInstance(__uuidof(Recordset));
try
{
VARIANT v;
m_Connection->Execute(L"Select * FROM File Database", &v, 0);
records->Open("Select * FROM File Database", _variant_t((IDispatch*)m_Connection, true),
adOpenDynamic, adLockOptimistic, adCmdTable);
}
catch(_com_error & e)
{
MessageBox(NULL, e.ErrorMessage(), "", 0);
}
Both the m_Connection->Execute call and the records->Open call result in an error message:
IDispatch Error #3092
that is to say, if I comment out the former, the latter does the same thing.
I've search MSDN for 3092, and found nothing useful. I am using W2000 if that helps. Any suggestions recieved with much rejoicing...
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
The Error Lookup util says 3092 means "There is no account for this computer in the security database." HTH
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
What does that mean ? I foudn that error number in MSDN, but found something different, so I thought that may be it - does it mean under Win2000 I need to provide a username/[assword combination for any database I use ?
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
I need to create an application.
and I need that MyApp will recieve all WM_KEYDOWN messages
before any other application and do somthing (like Beep).
Please help me.
|
|
|
|
|
You have to install global hook on keyboard .... To learn more about hooks - see SetWindowsHookEx function on MSDN Library.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com
|
|
|
|
|
Hi,
I'm thinking of writing a game (war simulation). In that game, i'll have a number of objects which will have "records" with initial information. I think i would let people modify the database so they can enter their own information. For instance 1 object from the object model could be a brigade.
If you start, you could have a number of records with historical brigades which people can then alter if they feel the info is incorrect.
I was thinking of storing them in textformat. Storing data this way is not optimized and i'll have to write my own functions to search on the "database" (=object model data saved to disk) for information. If the number of records is big, loading them into memory for speedy search operations is not doable.
In that case, a database system might be more interesting. I've thought of Access but that's of course not free. I had a look at Interbase, but that would be pure overkill since it has a database server/ client and so on. I would need something like Access but free. Having SQL support would be great but not a requirement.
Now i'm not even sure what i should do. I see four options:
1. Go with text files and write own search functions
2. Write the data binary and make an editor to manipulate object data.
3. Go with access and pretend to know nothing
4. Use an easy-to-use free database.
Any suggestions on what i would use best? In the case of database, any free database systems?
Also, does anybody know a good webpage for an analysis method? I learned several at the uni but they don't quit seem easy and practical enough.
Are there any freeware analysis tools around?
Thanks,
Bene
|
|
|
|
|
Another freebee database is mysql. It's still a client/server thingy but it's a bit lighter weight than Interbase.
Quite a lot depends on the ammount of data you are expecting to juggle. If there's only a moderate ammount it's generally more efficient to load the whole thing into memory at the beginning than use database access (whatever external format you chose).
If it's complex heirarchical data of limited size you might consider XML as a backing-store format. If you can get access to an XML editor it's a fairly nice way of organising data.
|
|
|
|
|
Thanks for the answer, i'll have a look at mysql then.
i was hoping for a non client server based database but of you say it's "lighter", then it might be okay anyway.
If i don't go with a database, i'll probably take a XML textbased database approach.
Anyway, thanks for the info
|
|
|
|
|
i took a quick look at mysql and it looks good but again client server (as you said) and that's not what i need. something in the lines of Access would have been great. Alas, i'll have to revert to XML text databases then. I have seen that apache and ibm both have a free parser. I took a quick look at the code from apache and man, pfew, this is nice code when it comes to syntax and reabability. I was impressed. A class factory (alla com), const correctness, good way of documenting (maybe a bit to short) and so on. A must-see if you are interested in improving your code readability.
|
|
|
|
|
Well, Access is not free, but the Jet database engine is (this is one of the two db engines that Access uses - the other one, SQL Server, is actually also free, in the form of MSDE. Look this up at MSDN). So if you don't need the Access UI to do the db manipulations, but instead write your own interface, you'll do just fine with Jet.
Of course, this is only works on Win platform.
Steen.
|
|
|
|