|
Hi there, I'm making a typelibrary with ATL for visual basic users. Does anyone know how you can create a static function so that it appears in the <globals> section when i look at my library with the objectbrowser in VB ?
|
|
|
|
|
Hi,
Just a small query:
I want to check if a certain module (.exe, i know its path) is running ? (VC++)
Thanks a lot.
|
|
|
|
|
If you are writting the other module try creating named Mutex
// Create named mutex
hNamedMutex = CreateMutex(NULL, TRUE, "The Other App");
// Test if the programm is already running
if(GetLastError() == ERROR_ALREADY_EXISTS) {
// Do Somthing
}
If you don't ...
the you have two approaches one is to enumerate the windows by using The EnumWindows function which enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE
If you want to enumerate the processes.
Under Windows 95, you must use functions from the ToolHelp32 group of APIs. Under Windows NT, you use functions from PSAPI.DLL, which is available in the Platform SDK.
// Sample Code FOR NT
#include <windows.h>
#include <stdio.h>
#include "psapi.h"
#pragma comment (lib, "psapi.lib")
void PrintProcessNameAndID( DWORD processID )
{
char szProcessName[MAX_PATH] = "unknown";
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if ( hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
}
}
// Print the process name and identifier.
printf( "%s (Process ID: %u)\n", szProcessName, processID );
CloseHandle( hProcess );
}
void main( )
{
// Get the list of process identifiers.
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
// Print the name and process identifier for each process.
for ( i = 0; i < cProcesses; i++ )
PrintProcessNameAndID( aProcesses[i] );
}
Hope this helps
Cheers
G. ALfadhly
<marquee>
It is Illogical to define an inventor by his invention
|
|
|
|
|
Hi,
I am trying to Terminate a process under WINNT and i am facing problems in loading the psapi.lib file.
Can i get some help???
Looking forward for a solution..
Nayan
|
|
|
|
|
These PSAPI.lib, is distributed in the Microsoft® Platform Software Development Kit (SDK).
after installing PLatform SDK make suer you also set the envirnoment parameters such as path and other thingys (run the batch file)
For the SDK download
http://msdn.microsoft.com/library/psdk/portals/mainport.htm
Hope that will help
Cheers
Alfadhly
<marquee>
If I had a hammer
|
|
|
|
|
Hi,
Just a small query:
I want to check if a certain module (.exe, i know its path) is running ?
Thanks a lot.
|
|
|
|
|
is there a way to capture the menus that pop up when any button is clicked in the tool bar controls provided in IE?
Subir
|
|
|
|
|
PrintScreen doesn't work? Try HyperSnap... search www.download.com or www.tucows.com
...or maybe you mean something else besides screen capture?
|
|
|
|
|
hi
yes i want all the info regarding the screen including the associated menus.
the problem is getting a handle to the individual menus.when i tried using GetMenu with the topmost window the return value is NULL.the problem is compounded by the fact that the structure MENUBARINFO is not recognised by my program.any pointers??
thanks
subir talukder
|
|
|
|
|
What is it you want?! The screen capture! OR the CMenu return!?
Be exact please.
|
|
|
|
|
hi
its the CMenu or rather the HMENU values that i want since i am using Platform SDK.
subir
|
|
|
|
|
for the SDK, use GetMenu() directly.
for the MFC, use a CMenu object and then the GetMenu() of that object.
|
|
|
|
|
Hello,
I guess the subject says most of what this is. I was using Delphi 5 and liked many of the components that have been made for it. I am wondering if there is any software or any way to convert Borland C+ Builder components or VCL to Visual Basic 6 or Visual Studio 6.
The main reason really is because I like the Coolform component which allows you to use an image like a skin almost. I have tried a couple skin type programs but I'm new to MVS and couldn't figure them out so this is why I am asking.
Any other help would be apreciated if you have a link or something.
Thanks
Chris Bunting
|
|
|
|
|
I have never seen any...
Everything is possible, but it's not easy to port Delphi Components to VC.
The Pascal to C++ process is not so bad, I have done it a couple of times
But Delphi uses VCL (Visual Component Library), and to easily port the components, you almost need to make a C++ VCL, not an easy task...
You can't use C++ Builder Components either, because they are also written in Pascal...
Good Luck, if you find a "Delphi Components to C++" anywhere, please let me know...
- Anders
|
|
|
|
|
You can't make them native components, but you could wrap the BCB component in an ActiveX wrapper. This would allow you to use the control in VB or VC. You would have to use Delphi's ActiveX tools though.
|
|
|
|
|
Hello. It's the first time i've made a program about hooks. So The program is very simple. I use a DLL. The keys pressed buy the user will be saved in a small Buffer till the user press ESC. Then the program should show the Buffer and stop.
Here is the DLL
_______________
#include <windows.h>
#include "Definiciones.h"
#pragma data_seg(".DATOS_COMPARTIDOS_DE_LA_DLL")
HHOOK hHookDLL = NULL;//
#pragma data_seg()
char Buffer[100] ="";
BOOL Bandera = FALSE;
BOOL WINAPI DllMain (HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
if (lpReserved)
{
if ( hHookDLL ) // Si ya se consigió el handle, salir
return FALSE;
hHookDLL = SetWindowsHookEx( WH_KEYBOARD, (HOOKPROC)KeyboardProc, hInstDLL, GetWindowThreadProcessId(GetActiveWindow(),NULL));
}
return TRUE;
case DLL_THREAD_ATTACH:
return TRUE;
case DLL_THREAD_DETACH:
return TRUE;
case DLL_PROCESS_DETACH:
if ( hHookDLL )
{
UnhookWindowsHookEx( hHookDLL );
hHookDLL = NULL;
}
}
return TRUE;
}
LRESULT CALLBACK KeyboardProc(
int idHook, // hook code
WPARAM wParam, // virtual-key code
LPARAM lParam // keystroke-message information
)
{
if (idHook < 0)
{
return (CallNextHookEx(hHookDLL, idHook, wParam, lParam));
}
else
{
LRESULT r =CallNextHookEx(hHookDLL, idHook, wParam, lParam);
if ((wParam >= 48) && (GetKeyState(wParam) &0xF0))//
{
Bandera = TRUE;
if (strlen(Buffer) < 100)
{
Buffer[strlen(Buffer)]= (char) wParam;
Buffer[strlen(Buffer)+1] = 0;
}
}
if (wParam == VK_ESCAPE)
{
Bandera = TRUE;//<-----------THE PROGRAM SEEMS NOT TO
//<----------- CHECK THE NEW STATE
MessageBox(NULL,Buffer,"Pressed ESC",MB_OK);
}
return(r);
}
}
int RetornaBandera(void)//returns true or false that's all
{
return Bandera;
}
Here is the program which loads statically the DLL
__________________________________________________
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
while(!RetornaBandera())//An exported function from the DLL which SHOULD
//return ESC was pressed
return 0;
}
Raúl
|
|
|
|
|
Hello!
Now I'm working under some multimedia system and need to play one video file in several windows simultaneously. I tried to use MCI devices for realize it, but have some problems: I can't open MCI device as shareable, i.e. another attempt of opening second MCI device using the same file return error MCIERR_UNSUPPORTED_FUNCTION.
Can anybody explain to me where am I wrong?
Thanks in advance,
Yuri Spivak
Software Developer, Russia
|
|
|
|
|
Hello,
I am trying to create a com component in vc++ ATL using the import directive to create the conneciton and recordset objects.
After successfully creating and opening the connection and recordset. The recordset returns the recordcount != 0. There is a function in recordset which returns the whole recordset as string. It gives an exception which i am able to catch with "catch (...)" kind of catch block.
Can anyone specify what could be the problem as well as the solution for this kind of a problem.
OS-win98. database sql-7.0 vc++-6.0 atl-3.0 ado-1.5
Thanks in Advance
Regards
Alpesh Makwana
|
|
|
|
|
How change volume of sound and cursor in system (9x)
|
|
|
|
|
It is necessary to create CListCtrl so that the user could not change the size of columns. Flag LVS_NOCOLUMNHEADER cannot be used. Columns should have header.
Help me.
|
|
|
|
|
Hi!
Try to handle WM_SETCURSOR, HDN_BEGINTRACKA/HDN_BEGINTRACKW and HDN_DIVIDERDBLCLICKA/HDN_DIVIDERDBLCLICKW messages:
BEGIN_MESSAGE_MAP(CMyHeaderCtrl, CHeaderCtrl)
...
ON_WM_SETCURSOR()
ON_NOTIFY_REFLECT_EX(HDN_BEGINTRACKA, OnBeginTrack)
ON_NOTIFY_REFLECT_EX(HDN_BEGINTRACKW, OnBeginTrack)
ON_NOTIFY_REFLECT_EX(HDN_DIVIDERDBLCLICKA, OnDividerDblClick)
ON_NOTIFY_REFLECT_EX(HDN_DIVIDERDBLCLICKW, OnDividerDblClick)
END_MESSAGE_MAP()
BOOL CMyHeaderCtrl::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
DWORD dwPos = ::GetMessagePos();
HDHITTESTINFO hdhti;
hdhti.pt.x = LOWORD( dwPos );
hdhti.pt.y = HIWORD( dwPos );
ScreenToClient( &hdhti.pt );
DefWindowProc( HDM_HITTEST, 0, ( LPARAM )&hdhti );
if ( !IsResizableColumn( hdhti.iItem ) && ( hdhti.flags & HHT_ONDIVIDER ) )
{
return true;
}
// Do default processing
return CHeaderCtrl::OnSetCursor(pWnd, nHitTest, message);
}
BOOL CMyHeaderCtrl::OnDividerDblClick(NMHDR* pNMHDR, LRESULT* pResult)
{
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
if ( !IsResizableColumn( phdn->iItem ) )
{
*pResult = 0;
return true;
}
// Do default processing
return false;
}
BOOL CMyHeaderCtrl::OnBeginTrack(NMHDR* pNMHDR, LRESULT* pResult)
{
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
if ( !IsResizableColumn( phdn->iItem ) )
{
*pResult = 1;
return true;
}
// Do default processing
return false;
}
Regards,
Nikolay Denisov
|
|
|
|
|
Hi
This Doc/View architecture is still giving me a headache. I'm using the Kodak Imaging Controls Admin, Thumbnail and Edit. I have a SDI with three panes. One shows the thumbnail control, the other shows the edit control, the other live video and the admin control resides in CMainFrame. Except I'm certain this isn't an efficient way of doing things because I end up with code like in CMainFrame:
CDocument * pDoc = GetActiveDocument();
POSITION pos = pDoc->GetFirstViewPosition();
while (pos)
{
CView * pView = pDoc->GetNextView(pos);
if (pView->IsKindOf(RUNTIME_CLASS(CEditView)))
((CEditView*) pView)->SetImage(strFullPathName);
if (pView->IsKindOf(RUNTIME_CLASS(CThumbView)))
((CThumbView*) pView)->SetImage(strFullPathName);
}
It seems I have two choices.
1/ Derive my ThumbView & CEditView class from some base class (eg. ImageView) and have virtual functions for eg. SetImage. But wouldn't this still require calling IsKindOf because I would only want to call ImageView and not say MovieView which I also have?
2/ Or do I put all the controls in the Document class and my views can just access them when needed? However because the thumbCtl is only concerned with displaying images, this seems incorrect
Of course there's the 3rd possibility that I've got everything wrong
Any advice is greatly appreciated.
Regards
Brendan
|
|
|
|
|
There are lots of solutions to this problem actually.
The most efficient is probably to derive your classes from a common CImageView class. Then you can override these functions in the actual view class to do what you want.
Now, instead of using the Doc/Vew mechanism for calling functions, which is inherantly error prone, you can instead create a publish/subscribe handler, also called Observer Pattern.
In your CDocument derived class, you create and instance of an Observer class. This is a class which simply takes a pointer to some other kind of class (CImageView in this case) and stores it in a list. Then, when you go to update, you need only get each item in the list (and since they're already stored as CImageView pointers, you need only do this pListItem->SetImage(...).
This avoids all the issues your dealing with by calling the functions directly, and then only for the objects which are actually CImageView's.
example (off the top of my head, so it may not compile):
#include <list>
class CImageViewObserver {
std::list<CImageView*> imageList;
public:
AddView(CImageView* pView){imageList.push_back(pView);}:
RemoveView(CImageView* pView){imageList.remove{pView);};
Update(CString s){};
}
Then, in your CThumbView or whatever simply put a call to AddView in your OnCreate(), or OnInitialUpdate() (but be sure to clear out your Observer in OnNew() to make sure you don't leave anything hanging around):
CMyDoc *pDoc = (CMyDoc*)GetActiveDocument();
pDoc->m_ivObserver.AddView(this);
Then, wherever you update, you need only pass the image path to the Observer::Update function.
|
|
|
|
|
Hi,
I know there is both std::string for standard asci text, and std::wstring for unicode chars...
My problem is that I want to write code that compiles both with and without unicode defined. With chars I just use TCHAR, and the preprocessor makes the work for me, is the anything defined when using STL?
TIA.
- Anders
|
|
|
|
|
The following is based on Microsoft's version of STL included in MSVC 6.0 SP3.
std::string is really just the definition std::basic_string<char> and std::wstring is std::basic_string<wchar_t>. If you want a TCHAR version you will have to declare your own as I have not found support for it directly: So in a header file you can define
#include <tchar.h>
#include <string>
using std::basic_string;
basic_string<tchar> tstring;
Then use tstring where you would use string 's or wstring 's. TCHAR will be preprocessed into the proper version for you.
Of course, you can apply this to all the character based STL using the 'basic_*' template definitions.
For example:
A build specific version of cout could be:
basic_ostream<tchar> tout;
It is up to you if you want to add these to the std namespace or your own. But it would not take much to create a header file that defines all character related stl classes in this manner. However, there are some interface functions that do not use the char_traits<> template (such as basic_ifstream::open which takes a const char * for the name of the file to open) so just be aware of these.
Good luck,
Chad
|
|
|
|
|