|
|
yeah seems like that class was exactly what i was looking for.
Thanks Rage!
And btw, do you happen to know a class which can return the current CPU id. I need that id to implement some security. (don't like this method of working though )
Greetings
Jens
|
|
|
|
|
JensB wrote:
yeah seems like that class was exactly what i was looking for.
If you need it, try and download it from PJ's website directly, I think the version is updated.
JensB wrote:
And btw, do you happen to know a class which can return the current CPU id. I need that id to implement some security. (don't like this method of working though
Maybe you could use GetSystemInformation.
Quoted from MSDN :
The GetSystemInfo function returns information about the current system.
VOID GetSystemInfo(
LPSYSTEM_INFO lpSystemInfo
);
typedef struct _SYSTEM_INFO {
union {
DWORD dwOemId;
struct {
WORD wProcessorArchitecture;
WORD wReserved;
};
};
DWORD dwPageSize;
LPVOID lpMinimumApplicationAddress;
LPVOID lpMaximumApplicationAddress;
DWORD dwActiveProcessorMask;
DWORD dwNumberOfProcessors;
DWORD dwProcessorType;
DWORD dwAllocationGranularity;
WORD wProcessorLevel;
WORD wProcessorRevision;
} SYSTEM_INFO;
Check it out directly in the MSDN for more info about the struct members.
Hope this helps.
~RaGE();
|
|
|
|
|
ok i will check it out directly @ msdn
I've downloaded the latest CSingleInstance v1.12 and implemented it on a new mdi application and it worked great.
BUT
When i try to implement it to my existing application, it doesn't work
i'll paste the appnameApp::InitInstance here:
CFile f;
SetRegistryKey("Company");
SetDialogBkColor(); // set dialog background color to gray
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
AddDocTemplate(new CSingleDocTemplate(IDR_MAINFRAME,
RUNTIME_CLASS(CMyAppNameDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CMyAppNameView)));
int iNrOfDialog = 1;
BOOL bGoOn=TRUE;
CDialog *pDialog;
int pushed;
m_bFromMain = false;
while (bGoOn)
{
switch (iNrOfDialog){
case 1:
{
pDialog = new CDlgWelcome2();
pDialog->DoModal();
delete pDialog;
pDialog = new CDlgWelcome();
pDialog->DoModal();
delete pDialog;
pDialog = new CDLogon();
pushed = pDialog->DoModal();
switch (pushed)
{
case (NEXT):
iNrOfDialog++;
break;
case (EXIT):
bGoOn = FALSE;
b_mExit = true;
break
}
delete pDialog;
break;
}
case 2:
{
pDialog = new CDlgList();
pushed = pDialog->DoModal();
....
so this code i don't have:
CMainFrame* pMainFrame = new CMainFrame;
m_pMainWnd = pMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
I've pasted the following code:
CInstanceChecker instanceChecker;
if (instanceChecker.PreviousInstanceRunning())
{
AfxMessageBox(_T("Previous version detected, will now restore it"), MB_OK);
instanceChecker.ActivatePreviousInstance();
return FALSE;
}
That i have put totally in the beginning of InitInstance.
And then before i go into the while repeating:
instanceChecker.TrackFirstInstanceRunning();
When i execute the program (use vc5) it gives an error on the line when i call the 'trackfirstinstanceRunning()'.
debug assertion failed:
sinstance.cpp
line: 145
What is on line 145:
ASSERT(AfxGetMainWnd() != NULL); //Did you forget to set up the mainfrm in InitInstance ?
I don't yet have a mainfrm, but a welcome form + logon form.
When can i know when the mainfrm is setup?
Any ideas?
|
|
|
|
|
ah sorry
i have put the trackfirstinstancerunning() at the end of InitInstance and now it works great (because then you have a mainwindow)
Anyway, thanks for the article
|
|
|
|
|
Here is another solution.
|
|
|
|
|
Is anyone who knows how to obtain a path to the folder in which there are dial up entries defined.
Please help
|
|
|
|
|
Why do you need a path to the folder? Can't you just use the Rasxxx() functions directly?
Here is an example of enumerating the RAS entries:
lpRasEntryName = (LPRASENTRYNAME)GlobalAlloc(GPTR, sizeof(RASENTRYNAME));
lpRasEntryName->dwSize = sizeof(RASENTRYNAME);
nRet = RasEnumEntries(NULL, NULL, lpRasEntryName, &cb, &cEntries);
if (ERROR_BUFFER_TOO_SMALL == nRet)
{
lpRasEntryName = (LPRASENTRYNAME)GlobalAlloc(GPTR, cb);
lpRasEntryName->dwSize = sizeof(RASENTRYNAME);
}
nRet = RasEnumEntries(NULL, NULL, lpRasEntryName, &cb, &cEntries);
if (nRet != ERROR_SUCCESS)
{
TRACE("RasEnumEntries failed: Error %d\n", nRet);
}
else
{
TRACE("Phone-book entries in the default phone book:\n\n");
for(i = 0; i < cEntries; i++)
{
TRACE("%s\n", lpRasEntryName->szEntryName);
lpRasEntryName++;
}
}
|
|
|
|
|
LPITEMIDLIST pidlDialUp;
LPSHELLFOLDER pDesktop,
pDialUp;
LPITEMIDLIST pidlTarget,
pidlTemp,
pidlDialUp;
LPENUMIDLIST pEnum;
DWORD dwRetrieved;
char szTemp[MAX_PATH];
HRESULT hr;
if(FAILED(SHGetDesktopFolder(&pDesktop)))
return NULL;
pidlDialUp = GetDialUpNetworkingPidl(pDesktop);
a piece of GetDialUpNetworkingPidl...
if(!pDesktop)
return NULL;
//get the pidl for Dial-Up Networking
hr = pDesktop->ParseDisplayName( NULL,
NULL,
L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{992CFFA0-F557-101A-88EC-00DD010CCC48}",
NULL,
&pidlDialUp,
NULL);
This is the ParseDisplayName from windows 98, and I have no clue how the name for dialupnetowking directory look under windows 2000
I need it for creating a shortcut on the desktop programmataticly.
|
|
|
|
|
|
I have one C++ dll with exported functions. But I dont have any details about the function's signatures.Is it possible to find out the same?
Vikram
|
|
|
|
|
No, not without the headers. if the exported functions end with @0 they take no parameters, @4 for 1 parameter, @8 for two parameters and so on. But I guess this won't help you much.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanx for the reply Grag,
Is it possible, by going inside the PE File structure or some another way of reverse engg?
|
|
|
|
|
Which is what Depends.exe does, but it still does not show you the function's signature.
|
|
|
|
|
Hi,
You can use the dependency walker to see the signatures.
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Why do you want or need the export signatures?
Trust in the code Luke. Yea right!
|
|
|
|
|
In order to make use of them, you need to know the return type and the parameter list. Normally, a .H file would provide this, but if you don't have that, other methods must be employed.
|
|
|
|
|
:(Your correct, of cource. I should have realised there was no header file(s) available. I do remember a project, someone submitted some where (possibly here), that took a .DLL and generated the needed files .h and .lib.
Trust in the code Luke. Yea right!
|
|
|
|
|
Hi,
I think I have hit the final roadblock in my bid to learn how to be comfortable with DLLs. I spend the whole of last night trying to figure this out, but to no avail.
I wanted to create a custom window control which all it does is draws a rectangle and blits a bitmap in it. I did it without a DLL and it worked without a hitch. Now, I used the same code and tried to write a DLL interface to it as follows:
//----------------------------------------------------------------------------------long _stdcall InitControl(HINSTANCE instance, HWND hwnd, HBITMAP hBitmap, int x, int y, int width, int height)
{
View::RegisterClass(instance);
//Offset::RegisterClass(instance);
background = new Bitmap(hBitmap);
pCtrl = new Controller(hwnd, background);
SetWinLong<controller *=""> (hwnd, pCtrl);
return 0;
}
//----------------------------------------------------------------------------------
The View::RegisterClass(instance) line is supposed to register my window control class. Using the debugger, I see that the RegisterClassEx(WNDCLASSEX) returns a non-zero value basically indicating success.
Now, in my controller class I try to create the window as:
View::MakeWindow (HWND, hwndParent, childID);
How the CreateWindowEx(...) returns zero. I verified all the parameters and they are not null. I even verified the parent handle (coming from the VB call) through Spy++ and it is indeed the same window with the right HINSTANCE. The error code string is "Cannot find window class". So, I am guessing the window did not get registered.
However, this same code works in a normal program. So, are there some rules when I am registering my own windows in a DLL. Do the parent window and the child window have to share the same DLL or something like that? I cannot understand what I am doing wrong.
Also, the VB declaration is like this:
Public Declare Function InitControl Lib "C:\BOXDLL.dll" (ByVal instance As Long, ByVal hwnd As Long, ByVal back As Long, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) As Long
and the call is:
InitControl App.hInstance, Me.hwnd, Me.Picture.Handle, 10, 10, 900, 200
I would really appreciate some help here. I have inching towards learning this for a whole month now and I am so close. However, this is the toughest problem I have encountered so far.
Also, I am not using MFC.
If you live around Stuttgart and help me, I will do your laundry for a week
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Are you creating an ActiveX control or what?
Need more input.
Trust in the code Luke. Yea right!
|
|
|
|
|
Nope, no ActiveX. However, I fixed it. So, it is all ok now
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Hi,
I am a real beginner in C programming.
I would like to create a sine wave and sample it. How do i start?
Any samples of programs are welcome
Thx
F.K
|
|
|
|
|
try something like this
double y [SAMPLES_NUMBER] ;
for (int i = 0 ; i < SAMPLES_NUMBER ; i++ )
y[i] = sin ( i ) ;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Or like this:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define PI 3.1415926
int main(int argc, char **argv){
double h, x,i,m;
h=15; // number of samples
m=2*PI/h; // sample interval
// create one sinus wave = 360 dgr
for (i=m; i<2*PI;) {
x = sin(i) ;
printf("At time %2.1f %f\n", i, x);
i=i+m;
}
return 0;
}
and display like this
http://www.charlespetzold.com/pw5/SineWave.c
jhaga
|
|
|
|
|
Hi,
I am using VC++, i thought a C code could work with VC++ but when i compile the code, it does not recognize printf
What is the problem?
F.K
|
|
|
|
|