|
Hi all,
How to vb script from a C++ code.
the script is like:
Function execute()
.
.
.
.
.
.
.
execute = obj.xml 'obj.xml is a xml
End Function
the script is working fine if i write it in a vbs file and double click on it.
but how to call it from a C++ code.
I tried with IScriptControl::Run but the its not giving any output.
SAFEARRAYBOUND rgsabound[] = { 0, 0 }; // 0 elements, 0-based
USES_CONVERSION;
psa = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
if (!psa)
{
return E_OUTOFMEMORY;
}
_variant_t outpar = m_pScriptControl->(m_bstrFunction, &psa); // m_bstrFunction = execute
but after execution of this statement outpar is empty.
|
|
|
|
|
Hello All
I have an application in which i use a navigate2 function but when i make a DLL , there is an exception in navigate2 function kindly look into the matter
Thanks
|
|
|
|
|
Are you sure that the exception is occurring within the Navigate2 function. Did you check for the parameters that you pass to the function.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
there are two programs one is exe ane another one is Dll in EXE there is no error and in Dll we face a exception error
i 'll pass the path of the file in Navigate2 like this
memset(szFolderPath, 0x00, MAX_PATH);
SHGetSpecialFolderLocation(NULL,CSIDL_RECENT, &pidl);
BOOL f = SHGetPathFromIDList(pidl,szFolderPath);
csTempPath.Format(_T("%s"),szFolderPath);
INT nTempIndex =csTempPath.Find(_T("Recent"));
csTempPath =csTempPath.Mid(0,nTempIndex);
csTempPath =csTempPath + _T("Local Settings\\Temp\\Sample") + csExt;
hDevice = CreateFile(csTempPath, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
NULL, CREATE_ALWAYS,0,NULL);
if(hDevice)
{
pView->Navigate2(csTempPath);
pView->EnableWindow(FALSE);
pView->ShowWindow(SW_NORMAL);
}
the same code successfully runs in an exe but when i make a dll ithe navigate function gives the error . when i debug the code error shows in this Class C:\....MFC\SRC\VIEWHTML.CPP
just have a look the code where excatly the error promts i'll mark the arrow
void CHtmlView::Navigate2(LPCTSTR lpszURL, DWORD dwFlags /* = 0 */,
LPCTSTR lpszTargetFrameName /* = NULL */,
LPCTSTR lpszHeaders /* = NULL */,
LPVOID lpvPostData /* = NULL */, DWORD dwPostDataLen /* = 0 */)
{
ASSERT(m_pBrowserApp != NULL);
COleSafeArray vPostData;
if (lpvPostData != NULL)
{
if (dwPostDataLen == 0)
dwPostDataLen = lstrlen((LPCTSTR) lpvPostData);
vPostData.CreateOneDim(VT_UI1, dwPostDataLen, lpvPostData);
}
COleVariant vURL(lpszURL, VT_BSTR);
COleVariant vHeaders(lpszHeaders, VT_BSTR);
COleVariant vTargetFrameName(lpszTargetFrameName, VT_BSTR);
COleVariant vFlags((long) dwFlags, VT_I4);
===>>> m_pBrowserApp->Navigate(vURL,
vFlags, vTargetFrameName, vPostData, vHeaders);
}
kindly solve the issue
thanks
|
|
|
|
|
Hi all,
i m developing a dll on visualC++ 2005 which needs to be made poratable to linux as well. I implemented the expected functionality in windows. Now i m looking whether any POSIX api's available which would work similarly on both windows as well as linux.As such i used standard C++ api's at the max but still there are few api's like createprocess() on windows doesn't seems to work on linux but i found out equivalent linux api's(fork() and execv()).
1)Is there any POSIX api which work on both Linux and windows and creates a child process how createprocess() does on windows and fork(),execv() combination does on Linux..?
2)Is there any POSIX api which would get list of files and subfolder names for a given folder name..?( i could not even find out a separate api on windows or linux which does this listing of files/subfolders.!!!)
Thanks in advance
kathir
|
|
|
|
|
1) Pretty much no.
2) For POSIX, look at dirent.h. Even better, there is (soon to be a part of the Standard) Boost Filesystem library that is portable.
|
|
|
|
|
I insalled DirectX10 SDK. but i dint see anything to work on video. now where can i download DirectShow? is there any sites where i can download?
|
|
|
|
|
DirectShow SDK is now not part of new DirectX SDK, u may find it in DirectX 9 SDK, it is now moved to platform SDK.
see this DirectShow 9.0[^]
|
|
|
|
|
so what needs to be done with the DirectX 10 that i have installed?? it say that To get the latest DirectShow SDK, download the latest version of the Windows SDK.
when i try to search with Windows SDK i am not getting the right downloadable.
|
|
|
|
|
search for platform SDK, may be this useful PSDK[^]
Chandrasekharanp wrote: so what needs to be done with the DirectX 10 that i have installed?
Direct Show requires DirectX Runtime only, DXSDK is not required if u have DSHOW SDK. if u bother about disk space u can remove DXSDK.
|
|
|
|
|
dear all
how to use Gaussion function to generate different image according to different k value? and also how to multiply with another image value f(x)? anyone has such code and let me make a refference. thanks a lot.
how the gaussion function convolute another one function, this is my first time to do this, so difficult, anyone give me suggestion and who can provide such code is better, thanks
Li Zhiyuan
modified on Tuesday, February 19, 2008 11:22 PM
|
|
|
|
|
li zhiyuan wrote: how to use Gaussion function to generate different image according to different k value?
AFAIK the Gaussian is a function depending on a variable, say x , and two parameters, say Xmean and Sigma .
I don't see any k in the above definition hence, I cannot understand your requirements. Maybe you have to further detail your problem.
Regarding the image generation: What kind of image do you need to generate?
What is image definition? Is it a curve depending on Gaussian values?
I think you'll need to explain more more clearly your problem.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
thanks, my problem is how to blur a image, it is a 2D digital image. like f(x,y).
by the way
A[(-1,-1),(0,-1),(1,-1);(-1,0),(0,0),(1,0);(-1,1),(0,1),(1,1)]
how to denote this array by for loop in my code? thanks
Li Zhiyuan
modified on Wednesday, February 20, 2008 7:17 AM
|
|
|
|
|
li zhiyuan wrote: thanks, my problem is how to blur a image, it is a 2D digital image. like f(x,y).
Typing blur in CP search engine make magical things happen [^].
li zhiyuan wrote: by the way
A[(-1,-1),(0,-1),(1,-1);(-1,0),(0,0),(1,0);(-1,1),(0,1),(1,1)]
Do you mean
int A[][3][2]={{{-1,-1},{0,-1},{1,-1}},{{-1,0},{0,0},{1,0}},{{-1,1},{0,1},{1,1}}}; ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I take full responsability on my "noobness" concerning threads.
I have been reading a lot of Newcomer's comments and tips (http://www.flounder.com[^]) and a lot of other places, books, and I still got a few question.
If I create a UI thread like this (in a simple dialog based application (in the OnInitDialog) ) :
m_pMyThread = new MyThread(this);
m_pMyThread->CreateThread(CREATE_SUSPENDED);
m_pMyThread->m_bAutoDelete = false;
m_pMyThread->ResumeThread();
And in my thread class, OnPlay and OnStop and thread messages called from my UI (with registered messages), the PostMessageW in the loop is to update a CStatic in the dialog:
ON_REGISTERED_THREAD_MESSAGE(WM_PLAY_THREAD_MESSAGE, OnPlay)
ON_REGISTERED_THREAD_MESSAGE(WM_STOP_THREAD_MESSAGE, OnStop)
void MyThread::OnPlay(WPARAM wParam, LPARAM lparam)
{
m_bRunning = true;
int i = 0;
while( m_bRunning)
{
m_pParent->PostMessageW( WM_THREAD_PLAYING_MESSAGE, (WPARAM) i, 0 );
Sleep(500);
i++;
}
TRACE("MyThread::OnPlay\n");
}
void MyThread::OnStop(WPARAM wParam, LPARAM lparam)
{
TRACE("MyThread::OnStop\n");
m_bRunning = false;
}
This (above) obviously does not work since the loop in OnPlay is "blocking" the thread messaging. If I do not loop in OnPlay , the OnStop message is handled properly.
I also tried this, and it does not work either:
m_pMyThread->PostThreadMessage(WM_QUIT, 0, 0);
So, What is the way to to stop the loop from my UI ? I tried adding a PeekMessage/TranslateMessage/DispatchMessage check in my loop to see if it would catch the message.
I cannot send a message to the thread.
Is modifying the m_bRunning with a direct call the preferred way ? like :
m_pMyThread->m_bRunning = false;
Thanks for any info tips and hints.
Max.
|
|
|
|
|
Maximilien wrote: Is modifying the m_bRunning with a direct call the preferred way ?
In this case, yes. To make the interface cleaner (instead of the inconsistent
post a message to start, set a variable to stop) you could add two public methods
to your thread class - Play() and Stop(). In Play(), post your WM_PLAY_THREAD_MESSAGE,
and in Stop(), you can set your running flag. That makes the thread control interface nice
and clean to the outside world.
Just my 2 cents - IMO, beyond the learning experience, the implementation is overkill...
a simple timer at 500ms intervals would make a much cleaner solution, without the need
for the secondary thread. Periodic timers are made for what you're doing there
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark.
Using a thread in our application will probably be overkill and not necessary, but I'm using the opportunity to learn a little bit on the side; Thread is one of the things I never really coded (was done by other people before).
BTW, the Sleep will not be in the final code! I will replace that with real functional code.
Still learning.
|
|
|
|
|
Hi,
- I use VC++ 6.0 in Win2k. I want built app to communication through USB port. How to start ?
Quang,
|
|
|
|
|
|
I have a CDialogBar which has a few CButton objects in it. Each CButton object contains an icon (no text) and I'd like them to appear like the buttons in a CToolBar do (flat, not raised, until the mouse hovers over the button). I used Spy++ to look at the button styles of the buttons in the tool bar, but only the tool bar has a hwnd - none of the buttons do, so it looks like the tool bar might be owner-drawing the buttons itself.
Is there a known set of button styles/window styles that one can set a CButton to and get it to appear like a button within a CToolBar does?
I can always look and see if someone has built an owner drawn CButton class which emulates a CToolBar button, but if this functionality is already built into the system then I'd rather use what's already here.
Thanks,
Jeff
|
|
|
|
|
|
Hay hi Guys
i have a single processor in my system and in my application i create more then 1 thread, so does it enhance my application, as at a given point of time only instruction can be executed, how does it make difference, does it speed up my application,
for example
i am retrieving 500 web logs from a site,
so if i create 10 threads in one go and in each thread i retrieve 1 log
i have to make 50 calls at go which will fetch those 500 logs,
so will it speed up the downloading or fetching up the logs
or should i go with application thread which will fetch 1 by 1,
which method will be useful...........
or any idea or implimentaion idea..........
i am not concerned about the server bandwidth or speed of my processor, my Question is doing the repetitive work in one thread at a time with multiple time is faster or doing it in multiple threads is faster . P.S. not concerned about UI too
thread t{ print 1;} /1st time
..
thread t{ print 1;}/100th time
OR
thread {t0,t1,t2,t3,t4,t5,t6,t7,t8,t9}{print 1;}/1st 10 run
..
thread {t0,t1,t2,t3,t4,t5,t6,t7,t8,t9}{print 1;}/last 10run=100
which will complete faster
Thanks
Swarup
modified on Tuesday, February 19, 2008 5:12 PM
|
|
|
|
|
It can helps if you need to have your application front-end no locked up because of some code.
for example, you have a UI that launch your log fetching thing, if you do that in a loop (in the default single thread), the UI will be locked until the loop is over.
But if you start the fetching thing in a different thread, then your UI will still be alive.
When you are dealing with concurrent connection, theoretically yes, it can increase the performance, but in practice, you will have some limitations due to the number of connections allowed, the bottleneck of your connection speed, ...
|
|
|
|
|
Thank you, but i am nt concerned bout UI part, becas i am handling UI in dif thread, i agree about UI, But what i am talking is, executing 100 threads is better or executing 1 thread is better.
example
1 thread called 100 times to do the same work (same work each time) OR
10 threas called 10 times to do the same work (same work each time), which method is faster, which method will complete faster, thats wht i am asking.............
Thanks again for ur reply......
thread t{ print 1;} /1st time
..
thread t{ print 1;}/100th time
OR
thread {t0,t1,t2,t3,t4,t5,t6,t7,t8,t9}{print 1;}/1st 10 run
..
thread {t0,t1,t2,t3,t4,t5,t6,t7,t8,t9}{print 1;}/last 10run=100
which will complete faster
Swarup
|
|
|
|
|
swarup wrote: is, executing 100 threads is better or executing 1 thread is better.
That depends on what each thread is doing.
swarup wrote: 1 thread called 100 times to do the same work (same work each time) OR
10 threas called 10 times to do the same work (same work each time), which method is faster, which method will complete faster
Neither will be faster than the other. On a single processor system, executing the same code 100 times, no matter how many threads you use to run the code will not execute any faster. If the code is 1,000 instructions, start-to-finish, the processor has to execute 1,000,000 instructions to get the job done. Since a single proc can only execute one instruction at a time, it doesn't matter how many threads you use, it's still 1,000,000 instructions to execute, one at a time.
Now, if you have multiple processors, the CPU can start executing more than one instruction at the same time. The process CAN run faster, but in no way is this guaranteed. It depends on what this code, that your executing 100 times, is doing and how it affects the CPU, memory controller, caching, I/O, ..., ...
swarup wrote: thread t{ print 1;} /1st time
..
thread t{ print 1;}/100th time
OR
thread {t0,t1,t2,t3,t4,t5,t6,t7,t8,t9}{print 1;}/1st 10 run
..
thread {t0,t1,t2,t3,t4,t5,t6,t7,t8,t9}{print 1;}/last 10run=100
which will complete faster
On a single core CPU, neither. You seem to have the misconception in your head that more threads = faster performance. Nothing could be further from the truth. Threading is a logical division of work, not a replacement for faster processing.
|
|
|
|
|