|
Could someone send me a sample program that loads font from a file (not already installed in Windows) and write text using that font? Also, to dump the displayed text in the loaded font to an image file (gif,jpg, bmp)...
Thanks
jpxavier@yahoo.com
|
|
|
|
|
the core functions you'll need are CreateScalableFontResource and AddFontResource.
Software | Cleek
|
|
|
|
|
I have string "0xFF070FF07" and I need to extract the int64 from it. I did try breaking up the string into high and lo parts and then bitshifting but I dont get the right value.
<pre>
unsigned __int64 alg_mask;
char *pHi,*pLo;
pLo = pHi + strlen(pHi) - 8;
unsigned int lo = strtoul(pLo, 0, 16);
*pLo = 0;
alg_mask = strtoul(pHi, 0 , 16);
alg_mask << 32;
alg_mask += lo;</pre>
How do I get my value out?
Thanks,
sb
|
|
|
|
|
What about StrToInt64Ex() ? Rolling your own is also very easy.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
This is more of an implementation question . I figured that the Gurus here can help me out .
I m working on an App thats like a diagnostic tool in VC++(SDI app) . There are different screens(windows shown) that have a variety of information that could be packaged as a summary or report or like a log .
My idea of implementing this was like :
All the screens (Windows) derive from a CDataLog class that has a method called :
AddToLog(string data)
All this func does is dump data to temporary text file .
When the user wants to see the Log this file is read back and displayed in the view . Is this a good methodology ? I plan to delete the file automatically once I ve drawn it on the View . How can Programmatically do this ? Plus for the File I/o does using MFC classes have an advantage over my intended raw C implementation (using FILE * , fopen , fprintf etc )
|
|
|
|
|
Well,
We know that services are not like a process, yuo can't just kill them.
So, how can we shut down a service programmatically ?
Thanks,
Shay
|
|
|
|
|
"net stop <servicename>" should would. You can use ShellExecute for this purpose.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Use the ControlService function.
|
|
|
|
|
Great answer, but....
Why it is not compiling ?
I tried the simple exmaple from MSDN and it will show SC_HANDLE as error.
Do I need to compile differently ?
Shay
|
|
|
|
|
What code have you written and what is the exact error message?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Let's see, actually I was able to solve this one, but I have another stupid question.
Why wouldn't printf compile for me ?????
Here is the exact code
<br />
#include <<windows.h>> <-ignore the extra <, it's there because of HTML<br />
#include <<stdio.h>><br />
#include "stdafx.h"<br />
<br />
<br />
int APIENTRY WinMain(HINSTANCE hInstance,<br />
HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine,<br />
int nCmdShow)<br />
{<br />
int nRetCode = 0;<br />
<br />
<br />
SERVICE_STATUS status;//the status for the stop request<br />
SC_HANDLE hService;//a handle to the SGDB service<br />
SC_HANDLE hSCManager;// a handle to the services database<br />
<br />
<br />
//open the service manager<br />
hSCManager = OpenSCManager (NULL,NULL,SC_MANAGER_ALL_ACCESS);<br />
<br />
//open the SGDB service<br />
hService = OpenService(hSCManager,"tlntsvr",SC_MANAGER_ALL_ACCESS);<br />
DWORD d=GetLastError();<br />
<br />
//stop the service<br />
if (ControlService(hService,SERVICE_CONTROL_STOP,&status)==0)<br />
{<br />
d=GetLastError();<br />
printf ("Error");<br />
return -1;<br />
}<br />
<br />
CloseServiceHandle (hService);//close the handle to the SGDB service<br />
CloseServiceHandle (hSCManager);//close the connection to the services datavbase<br />
<br />
<br />
<br />
return nRetCode;<br />
<br />
return 0;<br />
}<br />
error C2065: 'printf' : undeclared identifier
|
|
|
|
|
Hi,
I'm having a terrible time just trying to convert a CComBSTR to a string not char *, but string from <string.h>. Can anyone help? Or how about VARIANT to string - but I think its the same problem because it seems that I have to use the bstrval property of a VARIANT.
|
|
|
|
|
You can use OLE2A macro, for example,
USES_CONVERSION;
CComBSTR bstrSource = "Text to convert";
std::string sTarget = OLE2A(bstrSource);
Jaime
|
|
|
|
|
Thank you very much - that has made the next 2 crappy days 4 me better
|
|
|
|
|
I have an application that should be able to run either as a service or as a
user mode application. Currently, I call StartServiceCtrlDispatcher and if
it fails (error 1063) I run as user mode. But, StartServiceCtrlDispatcher
often takes several seconds before it fails when I'm running the app in user
mode, causing an annoying startup delay.
Can someone suggest a fast way to tell whether or not my application is
being started as a service? (Please do not suggest using command line
options.)
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
JT Anderson wrote:
Can someone suggest a fast way to tell whether or not my application is
being started as a service? (Please do not suggest using command line
options.)
I'm not sure what you've got against command line options - it would be the simplest solution...
You could call GetProcessWindowStation() and if it returns NULL, it is probably either running as a service or as a WTS process. If it is not NULL, then it was probably started by the user. Not perfect though.
Another way would be to get the user name that the process was started as. Generally services are run as the "Local Service" user (or something similar, can't remember exactly).
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
I found a peculiar problem when using CSharedFile.
Requirement:
I have data present in (BYTE*) which needs to be converted to HGLOBAL. The data is segmented, that is the entire data is present in 2-3 BYTE*.
What was done:
a) Created a CSharedFile and attached it to a CArchive object. Then the entire BYTE* data was archived using a while loop for each BYTE*.
b) Called CSharedFile::Detach to obtain the HGLOBAL data.
Problem:
The actual size of the data is 1184 bytes. But when checking the actual size of the memory allocated using GlobalSize() function the return value was 8192!!!
Please let me know what could be the reason for this?
You can reach me at s_adityapalanki@yahoo.com
Thanks and regards,
Aditya Palanki
|
|
|
|
|
This is the documented behaviour for GlobalSize .
|
|
|
|
|
Dear Johan,
Does this mean that the extra memory that is being allocated is normal?
Can you suggest any other way of creating an HGLOBAL?
Regards,
Aditya Palanki
|
|
|
|
|
Aditya_Palanki wrote:
Does this mean that the extra memory that is being allocated is normal?
Yes, it allocates in blocks. If your allocation size is not an exact multiple of the block, you'll get extra padding.
Aditya_Palanki wrote:
Can you suggest any other way of creating an HGLOBAL?
GlobalAlloc is the way of doing it. If the receiver needs to know the size actually allocated, just add this value to the beginning of the block, for example.
|
|
|
|
|
Hello,
When you press ESC or Enter on the dialog the dialog will close. How can I remove this I don't want my dialog to close.
|
|
|
|
|
|
|
Hi Folks,
I am trying to access a java webservice from Visual C++ .NET.
This java webservice has following method.
public void CreateDoc(String[][] values);
When I add webreference to this webservice in my visual studio .net environment, it changes the method to look like as following.
HRESULT CreateDoc(BSTR* arrayOfarrayOfString_1, int arrayOfarrayOfString_1_nSizeIs);
So, now in my visual c++ code, I have to pass a string array in this above format of BSTR*. I have tried a lot achieving this but no success !
Can anyone give me some idea how to do that ?
Thanks in advance,
Arun.
|
|
|
|