|
import the .dll and use the CreateInstance method.
Say the interface is named X.A
#import X.dll no_namespace
IAPtr ppA;
try {
CoInitialize(NULL);
ppA.CreateInstance(__uuidof(A));
ppA->Somemethod();
ppCrypt->Release();
CoUninitialize();
Thanks for the help,
Bill
|
|
|
|
|
The line
ppCrypt->Release();
should read
ppA->Release();
Thanks for the help,
Bill
|
|
|
|
|
I am trying to play around with an object library. Started looking at it in VB for simplicity. When I imported the type library using class wizzard to create wrappers only a few objects were inserted, when there are tons in VB object browser. Another thing I noticed when i tried to use VBs late-binding using 'createobject' i couldn't access these objects either.
Anyone any clues why I am having trouble accessing these objects from a type library, thats fine when used as a reference in VB?
Cheers
Rich
|
|
|
|
|
Hey all,
i have all these hexadecimal values(at least i think they are hexadecimal hehe) like this:
74 03 00 00 83 5b 83 8e 6d
etc...
now when you see these characters in notepad some are just blanks.
My question is, how can i make a char that contains a string for example with the hexadecimal values i just gave?
And is there an easier way then to add one character at a time because i have to make a string thats about 90 of those so it would be usefull
Thanks!
Kuniva
--------------------------------------------
|
|
|
|
|
They certainly look like hexadecimal to me. How are the values stored?
--
Andrew.
|
|
|
|
|
well they are stored binary in a file, but i dont want to extract it from there because its only a piece of it and the positions change etc... i just want to build the string from code, that has to be possible no?
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
use an ifstream to read the values and an ostringstream to build a string out of them. I have some articles on fstreams and ostringstream on CP.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
I've searched the code project site, but I have been unable to find any articles that show how to add a system dsn through code.
Could someone point me to a snippet of C++ that registers a DSN in the ODBC Data Sources?
I appreciate any help you can give me.
David Hisel -- http://www.hisel.com/
|
|
|
|
|
I don't have any code, but I can tell you how I've done it. Its really pretty easy. You need to add some entries to the system registry.
These entries define a DSN named APDB.
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\APDB]
"Driver"="C:\\WINNT\\System32\\SQLSRV32.dll"
"Server"="odyw2ksql02"
"Database"="Odyssey_APDB"
"LastUser"="obuser"
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources]
"APDB"="SQL Server"
|
|
|
|
|
Thanks!
This is very helpful, I appreciate it.
David Hisel -- http://www.hisel.com/
|
|
|
|
|
Here is some code to do this:
BOOL CreateSource(LPCSTR lpszDriver, LPCSTR lpszAttributes, BOOL bSystem )
{
char attr[500];
char driver[250];
if(lpszAttributes)
{
int mlen = strlen(lpszAttributes);
strcpy(attr,lpszAttributes);
char* ch = attr;
for (int i=0; i<mlen; i++,ch++) {if (*ch == '$') *ch = '\0';}
}
else
{
attr[0] = 0;
}
if(lpszDriver)
{
int mlen = strlen(lpszDriver);
strcpy(driver,lpszDriver);
strcat(driver,"\0");
}
else
{
driver[0] = 0;
}
WORD request;
if(bSystem) request = ODBC_ADD_SYS_DSN;
else request = ODBC_ADD_DSN;
return SQLConfigDataSource(NULL,request,driver,attr);
}
BOOL CreateAccessSource(LPCSTR lpszName, LPCSTR lpszPath, LPCSTR lpszDescription , BOOL bSystem )
{
char* szDesc;
szDesc=new char[500];
if(lpszDescription)
sprintf(szDesc,"DSN=%s$ DESCRIPTION=%s$ DBQ=%s$ FIL=MicrosoftAccess$ DEFAULTDIR=C:\\$$",lpszName,lpszDescription,lpszPath);
else
sprintf(szDesc,"DSN=%s$ DBQ=%s$ FIL=MicrosoftAccess$ DEFAULTDIR=C:\\$$",lpszName,lpszPath);
return CreateSource("Microsoft Access Driver (*.mdb)",(LPCSTR)szDesc,bSystem);
}
Pavel
Sonork 100.15206
|
|
|
|
|
This is great! Thank you.
Note: your code was mis-interpreted as HTML inside the first if block, look at the for loop to see what happened.
Could you send this via email to david at hisel dot com?
Thanks again,
David Hisel -- http://www.hisel.com/
|
|
|
|
|
I fixed it.
Pavel
Sonork 100.15206
|
|
|
|
|
My program depends on the user choosing a database, and then an images folder. Two issues arise:
If they browse to a random database, it will crash of course. If I can somehow take a look inside and see if it has a table called "tblTest" , I can potentially avert the crash. So thats
Q1 - how to peek in a db and see if its table has a particular name.
Q2 - If by chance or perversity the user chooses a random folder with none of the expected images in it, a grand crash ensues. How can I exit gracefully in case this happens? I dont mind terminating the app if need be - ideally they get a second chance to choose the right folder. The folder has a bunch of bmps in it.
I feel like there is no solution, but I have seen apps where such mistakes are forgiven...
thanks,
ns
|
|
|
|
|
ns wrote:
If by chance or perversity the user chooses a random folder with none of the expected images in it, a grand crash ensues. How can I exit gracefully in case this happens?
IMO, the real question you should be asking is "why is there a crash at all?" you should be checking for possible error situations everywhere, and acting accordingly at all times. it's a bad idea to assume every situation is a good one.
if you really need to exit immediately, try PostQuitMessage. but, that's really not much better than simply crashing, since the user has no clue as to what went wrong in either case.
-c
"I am angry that so many of the sons of the powerful and well-placed... managed to wangle slots in Reserve and National Guard units...Of the many tragedies of Vietnam, this raw class discrimination strikes me as the most damaging to the ideal that all Americans are created equal and owe equal allegiance to their country."
--Colin Powell
|
|
|
|
|
ns wrote:
If they browse to a random database, it will crash of course
You access the database through a db driver, right ? So, depending on the database (sql server, oracle, mysql, ...) you have system tables describing user tables.
And I swallow a small raisin.
|
|
|
|
|
Just handle the db errors - depending on the data access technology you're using, you may have to check error code or catch appropriate exception.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Hi there,
Is there way to show URL address in CRichEditCtrl like URL link in webpages ??
I mean when user hit the link in the CRichEditCtrl my program open browser …
Please help me …
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Yeah, but the user has to have RichEdit 2.0 on the system, so make sure you program a fail safe... most will have it but all it takes is that one who doesn't. But any way here you go.
<br />
<br />
HANDLE m_hRichEdit2 = LoadLibrary(_T("RICHED20.DLL"));<br />
if (m_hRichEdit2 == NULL) <br />
{ <br />
AfxMessageBox("Failed to initialize rich edit 2.0", MB_OK | MB_ICONEXCLAMATION); <br />
return FALSE; <br />
} <br />
<br />
CRichEditCtrl m_ctlEdit;<br />
if (m_hRichEdit2 != NULL)<br />
m_ctlEdit.SendMessage(EM_AUTOURLDETECT, (WPARAM)TRUE, 0); <br />
if (m_hRichEdit2 != NULL)<br />
m_ctlEdit.SendMessage(EM_AUTOURLDETECT, (WPARAM)FALSE, 0);<br />
<br />
<br />
if (m_hRichEdit2 != NULL)<br />
{<br />
::FreeLibrary(m_hRichEdit2);<br />
} <br />
<br />
<><><><><><><><><><><><><><>
Matthew R. Miller
mattrmiller@computersmarts.net
www.computersmarts.net
|
|
|
|
|
Coool, Thanks for sample
I have just a little question about your code ...
So, By your source code, if i have a URL address, RichEdit box make link for it, automaticly ... right ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Yup! Just like in Outlook or Outlook Express
<><><><><><><><><><><><><><>
Matthew R. Miller
mattrmiller@computersmarts.net
www.computersmarts.net
|
|
|
|
|
Ok, Thanks aloooot for your helps
With Best Regards
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
You bet!
<><><><><><><><><><><><><><>
Matthew R. Miller
mattrmiller@computersmarts.net
www.computersmarts.net
|
|
|
|
|
Hello again Mr.Matthew,
I'm sorry but i have other little problem ...
I used of your source code for using links in a rich edit box ...
But there is a problem, your code just change the mouse arrow and text case to link ... but when i click on that it doesn't work
I want to when i click on a link in rich edit, my program open IE browser ...
How can i do that ?
Please help me ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Just a sec... looking at my code.. I could have forgotten something. Be back in a minute
<><><><><><><><><><><><><><>
Matthew R. Miller
mattrmiller@computersmarts.net
www.computersmarts.net
|
|
|
|